By 3monkeys
via java.sys-con.com
Published: Sep 14 2006 / 12:16
Just open the stream over the network. Java has a class URL that will help you to connect to a remote computer on the Internet.
Comments
wytten replied ago:
Why is he reading 1 byte at a time in FileDownloader
ilazarte replied ago:
Commons IO:
http://jakarta.apache.org/commons/io/description.html
InputStream in = new URL ("http://jakarta.apache.org").openStream();
try {
System.out.println( IOUtils.toString( in ) );
} finally {
IOUtils.closeQuietly(in);
}
3monkeys replied ago:
From ilazarte's article, for a little added clarity:
<quote>In certain application domains, such IO operations are common, and this class can save a great deal of time. And you can rely on well-tested code.
For utility code such as this, flexibility and speed are of primary importance. However you should also understand the limitations of this approach. Using the above technique to read a 1GB file would result in an attempt to create a 1GB String object!<quote>
Voters For This Link (10)
Voters Against This Link (0)