thufir

Untitled

Aug 28th, 2013
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. package teln;
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.IOException;
  5. import java.io.InputStream;
  6. import java.io.InputStreamReader;
  7. import java.net.SocketException;
  8. import java.util.Properties;
  9. import org.apache.commons.net.telnet.TelnetClient;
  10.  
  11. public final class ConnectMUD {
  12.  
  13. private static String EOL = "/[#]/";
  14. private static TelnetClient tc;
  15.  
  16. public static void main(String[] args) throws SocketException, IOException {
  17. Properties props = PropertiesReader.getProps();
  18. String server = props.getProperty("server");
  19. String port = props.getProperty("port");
  20. port = "3000"; //just to make sure
  21. int intPort = Integer.getInteger(port).intValue();
  22. tc = new TelnetClient();
  23. tc.connect(server, intPort); //why can't I use intPort ?
  24. readLines(tc.getInputStream());
  25. }
  26.  
  27. private static void readLines(InputStream in) throws IOException {
  28.  
  29. InputStreamReader is = new InputStreamReader(in);
  30. StringBuilder sb = new StringBuilder();
  31. BufferedReader br = new BufferedReader(is);
  32. String read = br.readLine();
  33.  
  34. while (read != null) {
  35. sb.append(read);
  36. read = br.readLine();
  37. Parse.printString(read);
  38. }
  39. }
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment