How do I append a portion of byte array to a StringBuilder object under Java? I have a segment of a function that reads from an InputStream into a byte array. I then want to a
Something like below should do the trick for you.
byte[] buffer = new byte[3]; buffer[0] = 'a'; buffer[1] = 'b'; buffer[2] = 'c'; StringBuilder sb = new StringBuilder(new String(buffer,0,buffer.length-1)); System.out.println("buffer has:"+sb.toString()); //prints ab