File: download.js

package info (click to toggle)
libbsf-java 1%3A2.3.0%2Bcvs20050308a-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,460 kB
  • ctags: 1,264
  • sloc: java: 7,643; cpp: 2,514; xml: 1,773; jsp: 463; ansic: 182; makefile: 61; python: 45; sh: 29
file content (15 lines) | stat: -rw-r--r-- 475 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/* This is a simple demo of a JavaScript script that uses the Java
   URL class to download some content from some URL. */

URL_ADDR = "http://www.cnn.com/";

/* use a Java bean to get at the URL */
java.lang.System.err.println ("Connecting to .. " + URL_ADDR);
url = new java.net.URL (URL_ADDR);

/* read the content */
java.lang.System.err.println ("Downloading .. ");
content = url.getContent ();
while ((ch = content.read ()) != -1) {
  java.lang.System.out.write (ch)
}