Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Writing to URLConnection outputstream stops after 37MB

843790Jul 30 2008 — edited Jul 31 2008
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;
}
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 28 2008
Added on Jul 30 2008
6 comments
1,179 views