How can I convert a string to byte? For example, Byte.parseByte("255");
causes NumberFormatException
since (for some weird reason) byte
is signed
in java so the maximum value it can have is 127
.
So I need a function such that
public static byte toByte(String input) {
...
}
And for example toByte("255");
should return -1
(ie bits: 11111111)
Something like implementation of 2s complement