Class java.net.URL


  • URL = Uniform Resource Locator
  • WWW access: images, classes or text.
  • Security: Access check for URL's from different hosts as the server or client.
  • Loading text data is similar to reading from file.
public String open_url(String filename)
{
	try
	{
		return load( new BufferedReader(
			new InputStreamReader(
				new URL(filename).openStream())));
	}
	catch(FileNotFoundException file_not_found_exception)
	{
		System.err.println(filename+" read error:"
			+file_not_found_exception+"!");
		file_not_found_exception.printStackTrace();
	}

	return null;
}

Java Tutorial - Standard Classes Jens Trapp, 1997