Convert ByteArrayInputStream to String
Recently one of my friends wanted to get the string contained in a ByteArrayInputStream in Java. The method do this was bit tricky and I thought it'd be nice to share it.ByteArrayInputStream bais = // get your ByteArrayInputStream instance
int length = bais.available();
byte [] buff = new byte[length];
bais.read(buff);
That's it!!
@ WSO2, Inc.
The university life ended last Wednesday (7th May) and it was time to move into my first job in life :)I joined WSO2 Inc. on 12th May and it has been few busy days until today :). I am waiting for some build to complete and thought to jump in and blog on this.
I feel life has changed a bit compared with the life at the university, yet it is the same old me sitting in front of the computer :)
Subscribe to:
Posts
(
Atom
)
1 comment :
Post a Comment