怎么将String buffer = "01260A0B21A2"这样的格式转成String data[5] = {0x01,0x26,0x0A,0x0B,0x21,0xA2}
发布网友
发布时间:2022-05-21 05:30
我来回答
共1个回答
热心网友
时间:2023-10-15 21:45
package dataProcess;
public class Test {
public static void main(String[] args) {
// TODO Auto-generated method stub
String buffer = "01260A0B21A2";
char c[] = buffer.toCharArray();
String data[] = new String[6];
for(int i = 0;i < c.length;i += 2)
{
data[i/2] = "ox"+c[i]+c[i+1];
}
//for(int i=0;i<data.length;i++)
//{
//System.out.println(data[i]);
//}
}
}