关于java的telnet程序受信方面的问题!快点救救我呀!可以再加100分!
我用java做的telnet程序,发送命令如dos下的dir,返回一些正常的数据,如果我再发一便cd temp,结果受信的时候把上一次dir的结果,又重新收一遍了,怎么处理呀!我只想要我发完命令后改命令响应的结果!
socket = new Socket(address, port);
is = new BufferedInputStream(socket.getInputStream());
os = new BufferedOutputStream(socket.getOutputStream());
public byte[] receive() throws IOException {
int count = is.available();
byte buf[] = new byte[count];
if(count > 0) {
count = is.read(buf);
if(count < 0) throw new IOException("Connection closed.");
buf = negotiate(buf, count);}
return buf;
}