Hi
I have an applet which uploads files to a server, using the URLConnection. With smaller files this works fine, however when I upload a larger file (I'm testing with a 700MB file) this fails without giving any exception or message. I've put some println statements in and I can see that 39746560 bytes are getting written to the outputstream before it stops.
If anyone has any idea how I can fix this it would be greatly appreciated.
/**
* Puts the file into the URLConnection outputstream
* @param file - The file to upload
* @param out - The outputstream to write the file to
* @throws java.io.IOException
*/
private void pipe(File file, OutputStream out) throws IOException {
try{
byte[] buf = new byte[1024];
int nread;
long total = 0;
FileInputStream in = new FileInputStream(file);
System.out.println("File size = " + file.length());
synchronized (in) {
while((nread = in.read(buf, 0, buf.length)) >= 0) {
out.write(buf, 0, nread);
total += nread;
UploadDetail uploadDetail = new UploadDetail(total, file.length());
fireUploadDetailEvent(uploadDetail);
System.out.println(total);
}
}
out.flush();
buf = null;
}
catch(Exception e){
int i = 0;
}
}