|
|
|
|
|
|
|
|
|
Reading a URL
|
|
|
|
|
|
Organization: | Wolfram Research, Inc. |
Address: | 100 Trade Center Dr.
Champaign, IL 61820 |
|
|
|
|
|
|
An obvious use of Java is reading files off the internet. These files can be Mathematica packages (i.e., .m files) to be read into the kernel or notebooks (.nb files) to be opened in the front end. As a common foundation for these two operations, first a function must be created that takes an arbitrary file specified by a URL and copies it to a local temporary file. Java has a class called java.net.URL that represents a URL and allows data to be downloaded. In particular, there is an openStream method that returns a standard InputStream, which can be easily read from. Later, embellishments can be added that cause the file to be read into the kernel or opened as a notebook in the front end.
|
|
|
|
|
|
|
|
|
|
|
|
http://library.wolfram.com/examples/GetURL/
|
|
|
|
|
|
| GetURL.nb (48.4 KB) - Mathematica Notebook |
|
|
|
|
|
|
|
| | | | | |
|