Join 500+ Software Testing professionals. Solve problem and get your problem solved. Register Now!

1
read text file using Java

Solved 1 Answers 42 Views Programming
1 1
need code to read text file using Java

1 Answer

0
Best answer
0
Try below line of code to read file using Java.

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

public class BufferedReaderExample {

    public static void main(String[] args) {

        BufferedReader br = null;

        try {

            String sCurrentLine;

            br = new BufferedReader(new FileReader("C:\\testing.txt"));

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

        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                if (br != null)br.close();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }

    }
}
answered by (327 points)
selected by
1Comments
asked Aug 20, 2015 by Prasanth
recategorized Sep 9, 2015 by
How do I separate string using space and dot

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.
...