Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.io.FileReader;
- import java.io.IOException;
- import java.util.StringTokenizer;
- public class InputReadPerformance {
- public static void main(String[] args) {
- final InputReader in = new InputReader(new File("bigFile.txt"));
- final int n = in.nextInt();
- long total = 0L;
- double totalDouble = 0.0;
- for (int i = 0; i < n; i++) {
- final int u = in.nextInt();
- final int v = in.nextInt();
- final long difference = v - u;
- total += difference;
- }
- System.out.println(total);
- for (int i = 0; i < n; i++) {
- final double u = in.nextDouble();
- final double v = in.nextDouble();
- final double difference = v - u;
- totalDouble += difference;
- }
- System.out.println(totalDouble);
- System.out.println("End2");
- }
- static class InputReader {
- public BufferedReader reader;
- public StringTokenizer tokenizer;
- public InputReader(final File file) {
- try {
- reader = new BufferedReader(new FileReader(file));
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- }
- tokenizer = null;
- }
- public String next() {
- while (tokenizer == null || !tokenizer.hasMoreTokens()) {
- try {
- tokenizer = new StringTokenizer(reader.readLine());
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
- return tokenizer.nextToken();
- }
- public int nextInt() {
- return Integer.parseInt(next());
- }
- public double nextDouble() {
- return Double.parseDouble(next());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment