Java always has something easy implemeted 🙂

So this time, Java String has 2 constructors that take a byte[] array.

So:

  byte[] buf = new byte[1024]; //or whatever
[...] Fill all the byte array or part of it [...]
String str = new String(buf);
 
OR 
 
String str = new String(buf,start,limit);
//To create a string that starts from the start byte and it's limit long.

That’s it. Thanks for visiting the blog.