public static void read() throws IOException {
String readtext;
byte[] buff = new byte[1024];
int read;
if((read = telnetClient.getInputStream().read(buff)) > 0) {
readtext = new String(buff, 0, read);
//return readtext;
//System.out.println(new String(buff, 0, read));
System.out.println(readtext);
}
答案 0 :(得分:1)
您的答案不会返回字符串。您需要将String添加到方法签名并返回readtext
变量以获取所需的文本。
试试这个:
public static String read() throws IOException {
String readtext;
byte[] buff = new byte[1024];
int read;
if((read = telnetClient.getInputStream().read(buff)) > 0) {
readtext = new String(buff, 0, read);
}
return readtext;
}