Hi everyone!
I have a problem: In my current project, I have two parts: A client and a servlet. At one point, the servlet is supposed to send Files to the Client.
So far, I have implemented this by manually splitting the file into arrays of bytes, sending these arrays via an ObjectOutputStr eam, receiving them on Client side with a ObjectInputStre am and writing to a file. It works normally, but it's very slow and when the file is big, the Servlet throws a OutOfMemoryErro r exception, because of the Java heap space. (Not surprising, is it?)
The reason I'm using several byte arrays is, that I want to implement error correction - the client should check, if the data it received can be valid and if not request it again.
Now, I could get rid of the Error, if I sent the byte arrays directly after reading them and then overwrite them (maybe ask the Garbage Collector to work in between), but that doesn't solve the problem of speed.
So, I have a few questions:
Any suggestions? Tips? Ideas?
Greetings,
Nepomuk
I have a problem: In my current project, I have two parts: A client and a servlet. At one point, the servlet is supposed to send Files to the Client.
So far, I have implemented this by manually splitting the file into arrays of bytes, sending these arrays via an ObjectOutputStr eam, receiving them on Client side with a ObjectInputStre am and writing to a file. It works normally, but it's very slow and when the file is big, the Servlet throws a OutOfMemoryErro r exception, because of the Java heap space. (Not surprising, is it?)
The reason I'm using several byte arrays is, that I want to implement error correction - the client should check, if the data it received can be valid and if not request it again.
Now, I could get rid of the Error, if I sent the byte arrays directly after reading them and then overwrite them (maybe ask the Garbage Collector to work in between), but that doesn't solve the problem of speed.
So, I have a few questions:
- Is there a better Option than an ObjectOutputStr eam?
- What size would you recommend for one package?
- Is this way of doing it total crap and I should rewrite the whole thing? If so, any hints?
Any suggestions? Tips? Ideas?
Greetings,
Nepomuk
Comment