- 
                Notifications
    You must be signed in to change notification settings 
- Fork 0
Scanner
        nise-nabe edited this page Jan 3, 2015 
        ·
        1 revision
      
      static class Scanner {
    java.io.BufferedInputStream bis;
    public Scanner(java.io.InputStream is) {
      bis = new java.io.BufferedInputStream(is);
    }
    public String next() {
      StringBuilder sb = new StringBuilder();
      int b = ' ';
      try {
        for (; Character.isWhitespace(b); b = bis.read())
          ;
        for (; !Character.isWhitespace(b); b = bis.read()) {
          sb.append((char) b);
        }
      } catch (Exception e) {
        e.printStackTrace();
      }
      return sb.toString();
    }
    public int nextInt() {
      int r = 0, s = 1, b = ' ';
      try {
        for (; Character.isWhitespace(b); b = bis.read())
          ;
        if ((s = b == '-' ? -1 : 1) < 0) {
          b = bis.read();
        }
        for (; Character.isDigit(b); b = bis.read())
          r = r * 10 + b - '0';
      } catch (Exception e) {
      }
      return s * r;
    }
  }