package org.sl.util;
import org.apache.commons.net.telnet.TelnetClient;
import java.io.*;
import java.nio.ByteBuffer;
public class TelnetUtil {
String charset = null;
byte[] buff = new byte[2048];
TelnetClient telnetClient = new TelnetClient();
BufferedReader telnetReader = null;
BufferedWriter telnetWirter = null;
InputStream telnetIn = null;
OutputStream telnetOut = null;
public TelnetUtil() {
telnetClient = new TelnetClient();
}
/**
* 连接至服务器
* @param ip
* @param port
* @throws UnsupportedEncodingException
* @throws IOException
*/
public void connect(String ip, int port) throws UnsupportedEncodingException,IOException {
telnetClient.connect(ip,port);
setIOStream();
}
/**
* 连接至服务器
* @param ip
* @throws UnsupportedEncodingException
* @throws IOException
*/
public void connect(String ip) throws UnsupportedEncodingException,IOException {
telnetClient.connect(ip);
setIOStream();
}
void setIOStream() throws UnsupportedEncodingException {
telnetIn = telnetClient.getInputStream();
telnetOut = telnetClient.getOutputStream();
if(null==charset){