Menu
  • HOME
  • TAGS

possibly lossy conversion from int to byte

java,javax.comm

If you look at the error message: Main.java:10: error: incompatible types: possible lossy conversion from int to byte static byte[] bytearray = {0x02, 0x08, 0x16, 0x0, 0x00, 0x33, 0xC6, 0x1B}; ^ There is a small caret pointing to the value 0xC6. The reason for the issue is that java's byte...

Convert larger value hex string into bytes using java

java,hex,hexdump,javax.comm

Use method 2 and don't worry about the negative values in your byte array. Bytes are signed in java, so if you want to process your bytes as 0 to 255 instead of -128 to 127, AND each byte against 0xFF. This will promote the byte to an integer and...