I\'ve written a bit of code for downloading an episode of a webcast I do. It gets the URL of the episode and gets the place to save it. However, it only downloads up to 16MB and
here's another solution :
import java.io.*;
import java.net.*;
public class DownloadFile
{
public static void main(String args[]) throws IOException
{
java.io.BufferedInputStream in = new java.io.BufferedInputStream(new java.net.URL(episode.getUrl()).openStream());
java.io.FileOutputStream fos = new java.io.FileOutputStream(episode.getLocalSave());
java.io.BufferedOutputStream bout = new BufferedOutputStream(fos);
byte data[] = new byte[1024];
int read;
while((read = in.read(data,0,1024))>=0)
{
bout.write(data, 0, read);
}
bout.close();
in.close();
}
}
A quick look at the documentation of transferFrom:
public abstract long transferFrom(ReadableByteChannel channel, long position, long count)
WELL.
The value 1<<24 for the count (from the original question) equals 16M
I guess that's the answer to your question :-)