Skip to main content
3 of 3
edited tags
200_success
  • 145.6k
  • 22
  • 191
  • 481

Extracting text data from a file

Can I make this program that extracts text data from a file (size in MBs) even better performance-wise? I need to reduce the execution time.

import java.io.*;

public class ReadData {

    public static void main(String[] args) {

        FileReader input = null;
        BufferedReader br = null;

        try {

            input = new FileReader("C:/Projects/Test/HPCamDrv.log");
            br = new BufferedReader(input);
            String str;

            while ((str = br.readLine()) != null) {
                System.out.println(str);
            }
        }

        catch (IOException e) {
            e.printStackTrace();
        }

        finally {

            try {
                input.close();
                br.close();
            }

            catch (IOException x) {
                x.printStackTrace();
            }

        }
    }
}
Saikiran
  • 41
  • 1
  • 1
  • 2