Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static class FastScanner {
- BufferedReader br;
- StringTokenizer st;
- public FastScanner(InputStream stream) {
- br = new BufferedReader(new InputStreamReader(stream));
- st = new StringTokenizer("");
- }
- public FastScanner(String fileName) throws Exception {
- br = new BufferedReader(new FileReader(new File(fileName)));
- st = new StringTokenizer("");
- }
- public String next() throws Exception {
- while (!st.hasMoreTokens()) {
- st = new StringTokenizer(br.readLine());
- }
- return st.nextToken();
- }
- public int nextInt() throws Exception {
- return Integer.parseInt(next());
- }
- public long nextLong() throws Exception {
- return Long.parseLong(next());
- }
- public Double nextDouble() throws Exception {
- return Double.parseDouble(next());
- }
- public String nextLine() throws Exception {
- if (st.hasMoreTokens()) {
- StringBuilder str = new StringBuilder();
- boolean first = true;
- while (st.hasMoreTokens()) {
- if (first) {
- first = false;
- } else {
- str.append(" ");
- }
- str.append(st.nextToken());
- }
- return str.toString();
- } else {
- return br.readLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement