thufir

capturing a "return"

Sep 2nd, 2013
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.10 KB | None | 0 0
  1. package telnet;
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.IOException;
  5. import java.io.InputStreamReader;
  6. import java.util.Observable;
  7. import java.util.logging.Logger;
  8.  
  9. public class ConsoleReader extends Observable {
  10.  
  11.     private final static Logger LOG = Logger.getLogger(ConsoleReader.class.getName());
  12.     private String command = "help";
  13.  
  14.     public ConsoleReader() {
  15.     }
  16.  
  17.     public String getCommand() {
  18.         return command;
  19.     }
  20.  
  21.     public void read() {
  22.         Thread read = new Thread() {
  23.  
  24.             @Override
  25.             public void run() {
  26.                 BufferedReader bufferedInput = new BufferedReader(new InputStreamReader(System.in));
  27.                 do {
  28.                     try {
  29.                         command = bufferedInput.readLine();
  30.                         setChanged();
  31.                         notifyObservers();
  32.                     } catch (IOException ex) {
  33.                         System.out.println(ex);
  34.                     } finally {
  35.                     }
  36.                 } while (true);
  37.             }
  38.         };
  39.         read.start();
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment