I am trying to read the ASCII value of bytes in the inputstream. I have the following code
int bd = 0;
byte[] buffer = new byte[260];
while (true) {
try {
if ((bd = inputStream.read(buffer, 0, buffer.length)) > 0) {
Log.d("TAG", "Number of bytes from stream" + bd);
}
In order to read the value of bytes. I tried one of the following method from this SO example read byte value.
String s = new String(buffer,StandardCharsets.US_ASCII);
System.out.println("data from buffer s : " + s);
Result of s:"/9AAAAAAAAAAAAA=="
System.out.println("data from buffer s : " + parseInt(s)); -- error
String s2 = new String(buffer);
System.out.println("data from buffer s2: " + s2);
Result of s2: �@���������������
How can I get the ASCII values which are int ? I tried to convert string into Int using parseInt(s)
but I get thrown into NumberFormatException error