How to Read a file line by line using BufferedReader?

Ads
 

How to Read a file line by line using BufferedReader?

Hello Java developers.

I have studied java very well in last few months. A work is assigned to me in my company. Here I have many big text files. I have to read these files efficiently and the extract the business data and insert into database.

My problem is to find the best way to read the file in Java. I just searched the google and found that BufferedReader can be used.

So, help me and let's know How to Read a file line by line using BufferedReader, efficiently and using less memory.

Thanks

View Answers

February 9, 2013 at 12:12 AM

Hi,

You are right you can use the BufferedReader class for reading the big files which many range in many GB's is size.

It's not possible to read the whole file in memory. So, it's better to use the BufferedReader class.

The BufferedReader is present in java.io package. You can import

java.io.BufferedReader

in your program and use the class for reading the file line by line.

You can use the readLine() method of the class to read one line at a time very efficiently.

View the detailed example and code at Java Read File Line by Line - Java Tutorial page.

Thanks

Ads









Related Tutorials/Questions & Answers:
How to Read a file line by line using BufferedReader?
How to read big file line by line in java?
Advertisements
nio read file line by line
How to read a large text file line by line in java?
Java read file line by line
How to Read file line by line in Java program
Java Read File Line by Line - Java Tutorial
objective c read file line by line
How to read a line from a doc file
Read Specific Line from file Using Java
How to read a file line by line?
Java - How to read a string line per line
java - read file line by line in Java
Java Read File Line By Line, Video Tutorial of Java Read File Line By Line
How can i read a file from nth line onwards in java
Java read file line by line - Java Tutorial
How to write file by line in Java
how to write to file at the end of the line
Read file from the Nth line
Read file line by line in Java 8
Java file line reader
Line by Line reading from a file using Scanner Class
How to write file text In New Line
Java write to file line by line
Java Write To File By Line
How To Read Integer From Command Line In Java
How to read file in java
How can I execute a PHP script using command line?
How to Check Markup in PHP File from Command Line
How to extract a specific line from a text file? - IoC
Java file new line

Ads