i am working on a project(web application with java 2 ee) and i need to send an OutputStream
on a COM
port, the data type in the OutputStream
is byte[]
, one byte of this data is the address of the destination hardware which i am trying to communicate with .
problem is the address of the hardware has to be provided by the user within a web page. so how can i convert the string representation of a byte into a real byte
?
i hope the following code can make the problem more vivid
String data1 = "0xA1";
String data2 = "0xAB";
and i need to put the following line in OutputStream.
byte[] b = new byte[]{0xA1,0xAB};
some say usingorg.apache.commons.codec.binary.Base64
can solve the problem but i don't have any clue .
thank you in advance.