try {
byte[] ten1 = new byte[9];
byte[] ten2 = new byte[9];
byte[] ten3 = new byte[9];
byte[] ten4 = new byte[9];
Socket sc = new Socket("123.143.0.101", 512512);
OutputStream os = sc.getOutputStream();
InputStream is = sc.getInputStream();
DataOutputStream out = new DataOutputStream(os);
DataInputStream in = new DataInputStream(is);
out.write(res1);
in.read(ten1);
out.flush();
out.write(res2);
in.read(ten2);
out.flush();
out.write(res3);
in.read(ten3);
out.flush();
out.write(res4);
in.read(ten4);
out.flush();
我想问的是 我从机器那里得到是 4段数组 问题是 得到的是 10进制的 数组u 。。
1。要求是把它改变成 十六进制的字节数组。。
变成新的4段数组 tem1 tem2 tem3 tem4
2。将转好的数组 再转变成 String类型(这个有点难度 要求String和 byte字节数一致 否则就不对的)
最后变成新的4个String类型的就可以了
谢谢 高手帮忙!~!~搞定马上给钱!~!~
谢谢 高手帮忙谢谢
byte[] ten1 = new byte[9];
byte[] ten2 = new byte[9];
byte[] ten3 = new byte[9];
byte[] ten4 = new byte[9];
Socket sc = new Socket("123.143.0.101", 512512);
OutputStream os = sc.getOutputStream();
InputStream is = sc.getInputStream();
DataOutputStream out = new DataOutputStream(os);
DataInputStream in = new DataInputStream(is);
out.write(res1);
in.read(ten1);
out.flush();
out.write(res2);
in.read(ten2);
out.flush();
out.write(res3);
in.read(ten3);
out.flush();
out.write(res4);
in.read(ten4);
out.flush();
我想问的是 我从机器那里得到是 4段数组 问题是 得到的是 10进制的 数组u 。。
1。要求是把它改变成 十六进制的字节数组。。
变成新的4段数组 tem1 tem2 tem3 tem4
2。将转好的数组 再转变成 String类型(这个有点难度 要求String和 byte字节数一致 否则就不对的)
最后变成新的4个String类型的就可以了
谢谢 高手帮忙!~!~搞定马上给钱!~!~
谢谢 高手帮忙谢谢
是这样
byte[] ten1 = new byte[9]{1,2,3,4,5,6,7,8,9};
还是
byte[] ten1 = new byte[9]{'1','2','3','4','5','6','7','8,'9'};
ten1 是byte字节数组 假设我用System.out.print得到返回的信息 是
( -60-60-60-60-60-60-60-60-60) 那么9个 字节数组 就是 十进制的
我想要把它变成 C4C4C4C4C4C4C4C4C4 就变成全部都是十六进制的
我想能不能直接返回的就是十六进制 或者得到的是十进制 再转成 十六进制。。
最后就是把 这个十六进制字节数组 转成String 类型(而且字节数要相同。。否则就不对的)
请大虾们帮助啊!~~~碰到难题了!~!~
先谢谢了!!~~搞定马上给钱!~!~
用第二个参数指定的基数返回第一个参数的字符串表示形式
我用你方法 还是有问题 你的2个参数是 int 的 前面一个放 我返回得到的数组 错误 后面放 进制数 错误
tostring 报错误。。
好像不能用啊
大概是我不懂吧 大虾帮我写写吧
谢谢啦!~~
byte[] b ={'a','b',1,'2',3,12,22,33,44};
System.out.println(Integer.toHexString(b[5]));
测试的代码..........差不多就是这个思路...
toHexString 不能用的 是不对的 不好意思 大虾
我要得到的是十六 进制数组 再转成 String类型 最后 数组 和 String类型要比对的
用你的方法 比对时错误的 而且 我还要测试 最后String类型转好以后 打印出来的是不是乱码 是乱码 就对了!~!~大虾帮我写写吧!~!~
u[i] = Integer.toHexString(u[i]);//转化成十六进制
u[i] = u[i]+"";//转化成字符串
你把数组的一个元素传进去,后面16 不可以?
大哥 接下来 转成 String 帮下忙 写一下吧