2013年9月10日星期二

Pass byte hexadecimal string problem

String str = "0XCC";
byte [] b = new byte [10];
b [0] = (byte) str; / / Here how to convert byte str ah ? so that the compiler does not pass
/ / 0XCC is read out from the database string
------ Solution ------------------- -------------------------
str.getBytes ()
------ Solution ------- -------------------------------------
		String str="0XCC";
byte[] b = str.getBytes();
System.out.println((char)b[0]);

---- - For reference only ---------------------------------------
b [0 ] = (byte) "0XCC". getBytes (); / / compiler is not passed ah
------ For reference only ----- ----------------------------------



b [0] = (byte) "0XCC". getBytes (); compiler does not pass ah
------ For reference only - -------------------------------------
you doing ah strong turn directly b = str.getBytes ();

没有评论:

发表评论