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();
String temps1 = new String(tem1);
for (int v = 0; v < 9; v++) {
System.out.print(temps1);//byte转 String 有问题
大虾们 我比较了 System.out.print(temps1);
System.out.print(tem1);
有不一样 因为我得到数组时 一段乱码 转成 String 类型 后
比对了一下 和原来的 得到 数值不一样 有出入
请哪位大虾 帮助一下 把 得到的 tem1 乱码 转到 String 一样就可以了1!~
感激 !!~
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();
String temps1 = new String(tem1);
for (int v = 0; v < 9; v++) {
System.out.print(temps1);//byte转 String 有问题
大虾们 我比较了 System.out.print(temps1);
System.out.print(tem1);
有不一样 因为我得到数组时 一段乱码 转成 String 类型 后
比对了一下 和原来的 得到 数值不一样 有出入
请哪位大虾 帮助一下 把 得到的 tem1 乱码 转到 String 一样就可以了1!~
感激 !!~
* 把byte[]类型转换成String
* @param bt byte[]
* @return String
*/
public String getString(byte[] bt) {
BASE64Encoder enc=new BASE64Encoder();
return enc.encode(bt);
}