Checkout our demo site to practice selenium https://magento.softwaretestingboard.com/

1 like 0 dislike
191 views
in Programming by
recategorized by
need code to read text file using Java

1 Answer

0 like 0 dislike
by The go-to Tester (327 points)
selected by
 
Best answer
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();
            }
        }

    }
}
asked Aug 20, 2015 in Programming by Prasanth
recategorized Sep 9, 2015 by
How do I separate string using space and dot


This site is for software testing professionals, where you can ask all your questions and get answers from 1300+ masters of the profession. Click here to submit yours now!

1.4k questions

1.6k answers

866 comments

1.9k users

...