Advertisement
SchrodZzz

MyScanner

Oct 16th, 2018
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.03 KB | None | 0 0
  1.     static class MyScanner {
  2.         BufferedReader br;
  3.         StringTokenizer st;
  4.  
  5.         public MyScanner() {
  6.             br = new BufferedReader(new InputStreamReader(System.in));
  7.         }
  8.  
  9.         String next() {
  10.             while (st == null || !st.hasMoreElements()) {
  11.                 try {
  12.                     st = new StringTokenizer(br.readLine());
  13.                 } catch (IOException e) {
  14.                     e.printStackTrace();
  15.                 }
  16.             }
  17.             return st.nextToken();
  18.         }
  19.  
  20.         int nextInt() {
  21.             return Integer.parseInt(next());
  22.         }
  23.  
  24.         long nextLong() {
  25.             return Long.parseLong(next());
  26.         }
  27.  
  28.         double nextDouble() {
  29.             return Double.parseDouble(next());
  30.         }
  31.  
  32.         String nextLine() {
  33.             String str = "";
  34.             try {
  35.                 str = br.readLine();
  36.             } catch (IOException e) {
  37.                 e.printStackTrace();
  38.             }
  39.             return str;
  40.         }
  41.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement