[英]Decoding Data Stream From Socket Connection in Java
I have the code below to read from my socket connection. 我有以下代码可从我的套接字连接中读取。
String line = null;
try{
BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
while((line = reader.readLine())!=null){
System.out.println(line);
}
reader.close();
}catch(IOException e){
}
I can successfully connect to it using a TCP client, but when I try and send a message in Hex I am getting unrecognisable characters in return. 我可以使用TCP客户端成功连接到它,但是当我尝试以十六进制发送消息时,得到的字符却无法识别。
I am suspecting I need to convert to ASCII, but how would this be done. 我怀疑我需要转换为ASCII,但是该怎么做。
Any help would be appreciated. 任何帮助,将不胜感激。
Readers and Writers are for text. 读者和作家都是文字。 Use the input and output streams directly, or via a BufferedOutputStream with appropriate flushing.
直接使用输入和输出流,或通过带有适当刷新的BufferedOutputStream使用输入和输出流。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.