Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package teln;
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStream;
- import java.io.InputStreamReader;
- import java.net.SocketException;
- import java.util.Properties;
- import org.apache.commons.net.telnet.TelnetClient;
- public final class ConnectMUD {
- private static String EOL = "/[#]/";
- private static TelnetClient tc;
- public static void main(String[] args) throws SocketException, IOException {
- Properties props = PropertiesReader.getProps();
- String server = props.getProperty("server");
- String port = props.getProperty("port");
- port = "3000"; //just to make sure
- int intPort = Integer.getInteger(port).intValue();
- tc = new TelnetClient();
- tc.connect(server, intPort); //why can't I use intPort ?
- readLines(tc.getInputStream());
- }
- private static void readLines(InputStream in) throws IOException {
- InputStreamReader is = new InputStreamReader(in);
- StringBuilder sb = new StringBuilder();
- BufferedReader br = new BufferedReader(is);
- String read = br.readLine();
- while (read != null) {
- sb.append(read);
- read = br.readLine();
- Parse.printString(read);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment