I am not able to download large files from the net ( more than 1 mb file ). However, my program is able to download those large files from the localhost. Is there anything else that i need to do to download large files? Here is the code snippet:
try {
//connection to the remote object referred to by the URL.
url = new URL(urlPath);
// connection to the Server
conn = (HttpURLConnection) url.openConnection();
// get the input stream from conn
in = new BufferedInputStream(conn.getInputStream());
// save the contents to a file
raf = new RandomAccessFile("output","rw");
byte[] buf = new byte[ BUFFER_SIZE ];
int read;
while( ((read = in.read(buf,0,BUFFER_SIZE)) != -1) )
{
raf.write(buf,0,BUFFER_SIZE);
}
} catch ( IOException e ) {
}
finally {
}
Thanks in advance.