How to read from a text file in Java

There are several ways to read a text file in Java. Here is one of them:

try {
	        FileInputStream stream = new FileInputStream(file);
	        InputStreamReader reader= new InputStreamReader(stream);
	        BufferedReader breader = new BufferedReader(reader);
	        String line = null;
	        while ((line = breader.readLine())!= null) {
	    catch (FileNotFoundException ex) {
	    } catch (IOException e) {

Leave a Reply

Your email address will not be published. Required fields are marked *