Use ByteArrayOutputStream instead of stringbuilder to read bytes