File: download.js

package info (click to toggle)
libbsf-java 1%3A2.4.0-5
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch, wheezy
  • size: 3,028 kB
  • ctags: 2,480
  • sloc: java: 5,373; xml: 226; ansic: 182; python: 57; makefile: 18
file content (16 lines) | stat: -rw-r--r-- 478 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/* 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)
}