Wolfram Library Archive


All Collections Articles Books Conference Proceedings
Courseware Demos MathSource Technical Notes
Title Downloads

Reading a URL
Author

Wolfram Research, Inc.
Organization: Wolfram Research, Inc.
Address: 100 Trade Center Dr.
Champaign, IL 61820
Phone: (217) 398-0700
Fax: (217) 398-0747
Email: infocenter@wolfram.com
URL: http://www.wolfram.com
Description

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.
Subjects

*Information Science and Technology > Internet
*Wolfram Technology > Linking Technology > J/Link
URL

http://library.wolfram.com/examples/GetURL/
Downloads Download Wolfram CDF Player

Download
GetURL.nb (48.4 KB) - Mathematica Notebook