Skip to Main Content

Java Programming

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!

How to read byte array from network using servlet/jsp

807603Nov 16 2007 — edited Nov 16 2007
hai
I am in need of reading a byte array from the network using servlet.
Actually reading as a string and converting it into a byte array is not worthy, why because it makes some precision loss so I am in need of reading byte array itself. I have used ServletInputStream to read the byte array but it does not reads exactly.

my code is here...

int n=request.getContentLength();
byte[] data=new byte[n];
InputStream inputStream=request.getInputStream();
input.read(data);

If I convert the readed byte array to String and print it nothing is there. But
got the byte array. Also checked with the input byte array it does not same.

Please, anyone help me to solve this problem.

Thanks in advance.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 14 2007
Added on Nov 16 2007
3 comments
1,377 views