Last active
December 2, 2016 12:42
-
-
Save rohithpeddi/76f7d27902f97ba398d57bbf99931f1e to your computer and use it in GitHub Desktop.
Class to read input faster
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static class FastReader | |
{ | |
BufferedReader br; | |
StringTokenizer st; | |
public FastReader() | |
{ | |
br = new BufferedReader(new | |
InputStreamReader(System.in)); | |
} | |
String next() | |
{ | |
while (st == null || !st.hasMoreElements()) | |
{ | |
try | |
{ | |
st = new StringTokenizer(br.readLine()); | |
} | |
catch (IOException e) | |
{ | |
e.printStackTrace(); | |
} | |
} | |
return st.nextToken(); | |
} | |
int nextInt() | |
{ | |
return Integer.parseInt(next()); | |
} | |
long nextLong() | |
{ | |
return Long.parseLong(next()); | |
} | |
double nextDouble() | |
{ | |
return Double.parseDouble(next()); | |
} | |
String nextLine() | |
{ | |
String str = ""; | |
try | |
{ | |
str = br.readLine(); | |
} | |
catch (IOException e) | |
{ | |
e.printStackTrace(); | |
} | |
return str; | |
} | |
} | |
public static void main(String[] args) | |
{ | |
FastReader fs=new FastReader(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment