I have a problem that's been bothering me for a month already.
I write a code that download url file to my workspace. My code works well for any size file.
Here is my code:
But, i want to do it automaticly, so i packaged this code by Java Service. I use tomcat 7.0.12.
Now, this code works well only for small files. If i try to download large file like the second one, I get this error for "byteCount = in.read(buffer);" line:
java.net.SocketException: Connection reset
java.lang.NullPointerException at MyService.downloadFilesToWorkspace(MyService.java:153)
If someone has any idea why this happens and what sould i change, i would be glad to hear them.
Have you got an answer?
I have exactly the same problem. I have tried different solutions but with the same result.
Goes well for small files, not for big ones.
The read() function stops until it get's connection reset after a while.
Also tried apache.commons.io.FileUtils.getURLToFile(URL ..., File ...) but with same result.
Curious, is that instead of getting an url file (http://...), I tried with the same file (downloaded by browser) already saved at my disk (file:///...). And from filesystem it works with the same code.
I suspect the problem is the connections opened.
Hope for a solution,
Joined: Jun 12, 2011
Unfortunately, I did not find a solution then. It was part of my BSc's finish project and i was supposed to have it ready by the deadline.
Without a solution, I changed the project design so that the operation <file downloading> will not occur automatically by Java Servise but by the task scheduler of the operating system.
But still nice to find people who read my problems