Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Scanner
- {
- BufferedReader in;
- StringTokenizer token;
- String delim;
- Scanner(Reader reader)
- {
- in=new BufferedReader(reader);
- token=new StringTokenizer("");
- this.delim=" \n";
- }
- Scanner(Reader reader, String delimeters)
- {
- in=new BufferedReader(reader);
- token=new StringTokenizer("");
- this.delim=delimeters;
- }
- public boolean hasNext() throws IOException
- {
- while(!token.hasMoreTokens())
- {
- String line=in.readLine();
- if(line==null) return false;
- token=new StringTokenizer(line,delim);
- }
- return true;
- }
- String next() throws IOException
- {
- return hasNext()?token.nextToken():null;
- }
- int nextInt() throws IOException
- {
- return Integer.parseInt(next());
- }
- long nextLong() throws IOException
- {
- return Long.parseLong(next());
- }
- double nextDouble() throws IOException
- {
- return Double.parseDouble(next());
- }
- int[] nextInts(int n) throws IOException
- {
- int[] res=new int[n];
- for(int i=0;i<n;i++)
- res[i]=nextInt();
- return res;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment