Saliya's Blogs

Mostly technical stuff with some interesting moments of life

Convert ByteArrayInputStream to String

1 comment
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!!

1 comment :

Post a Comment

@ WSO2, Inc.

1 comment
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 :)

1 comment :

Post a Comment