Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.79 KB | None | 0 0
  1. package jpb;
  2.  
  3. import java.io.*;
  4.  
  5. public class SimpleIO {
  6.   private static InputStreamReader streamIn =
  7.     new InputStreamReader(System.in);
  8.   private static BufferedReader in =
  9.     new BufferedReader(streamIn, 1);
  10.  
  11.   // Displays the string s without terminating the current
  12.   // line
  13.   public static void prompt(String s) {
  14.     System.out.print(s);
  15.     System.out.flush();
  16.   }
  17.  
  18.   // Reads and returns a single line of input entered by the
  19.   // user; terminates the program if an exception is thrown
  20.   public static String readLine() {
  21.     String line = null;
  22.     try {
  23.       line = in.readLine();
  24.     } catch (IOException e) {
  25.       System.out.println("Error in SimpleIO.readLine: " +
  26.                          e.getMessage());
  27.       System.exit(-1);
  28.     }
  29.     return line;
  30.   }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement