byte[] tem1 = new byte[9]; Socket sc = new Socket("143.41.0.161", 555); OutputStream os = sc.getOutputStream(); InputStream is = sc.getInputStream(); DataOutputStream out = new DataOutputStream(os); DataInputStream in = new DataInputStream(is); out.write(tt); in.read(tem1); out.flush(); for (int v = 0; v < tem1.length; v++) { int t; t = tem1[v]; if (tem1[v] < 0) t += 256; System.out.print(Integer.toHexString(t)); ap1 += Integer.toHexString(t); System.out.println(ad1); 返回得到的是 12dct6789 因为他把第一个字节 01 0去掉了 所以想问 下 怎么样才可以返回得到的信息是 01020d0c0t06070809 还有就是 怎么把 小写字母变成大写 感激大虾们!~~
又是怎么转的
package com.xiaoyong;public class StringTest { private String str = "01020d0c0t06070809"; public void output() {
System.out.println(str.toUpperCase());
} public static void main(String[] args) {
new StringTest().output();
}
}
你说这是一个数值转换的
当int时:此数值是超出范围了的
byte[] tem1 = new byte[9];
Socket sc = new Socket("143.41.0.161", 555); OutputStream os = sc.getOutputStream();
InputStream is = sc.getInputStream();
DataOutputStream out = new DataOutputStream(os);
DataInputStream in = new DataInputStream(is);
out.write(tt);
in.read(tem1);
out.flush();
for (int v = 0; v < tem1.length; v++) {
int t;
t = tem1[v];
if (tem1[v] < 0)
t += 256;
System.out.print(Integer.toHexString(t));
ap1 += Integer.toHexString(t);
System.out.println(ad1);
返回得到的是 12dct6789
因为他把第一个字节 01 0去掉了 所以想问 下 怎么样才可以返回得到的信息是
01020d0c0t06070809 还有就是 怎么把 小写字母变成大写
感激大虾们!~~