B
bruce_phipps
I want to download a 4 meg binary file from a Linux server to my
standalone Java client program.
An example I have seen first creates a URL object, then creates an
Input Stream, then downloads data via a data buffer using read() and
write():
URL url = new URL("http://test.com/files/myfile");
InputStream in = url.openStream();
byte[] buf = new byte[4*1024]; //4k buffer
int bytesRead;
while ((bytesRead=in.read(buf)) != -1) {
out.write(buf,0,bytesRead);
}
Are there any simpler methods to do this?
Thanks
Bruce
standalone Java client program.
An example I have seen first creates a URL object, then creates an
Input Stream, then downloads data via a data buffer using read() and
write():
URL url = new URL("http://test.com/files/myfile");
InputStream in = url.openStream();
byte[] buf = new byte[4*1024]; //4k buffer
int bytesRead;
while ((bytesRead=in.read(buf)) != -1) {
out.write(buf,0,bytesRead);
}
Are there any simpler methods to do this?
Thanks
Bruce