package com.java2novice.files; import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; public class ReadLinesFromFile { public static void main(String a[]){ BufferedReader br = null; String strLine = ""; try { br = new BufferedReader( new FileReader("fileName")); while( (strLine = br.readLine()) != null){ System.out.println(strLine); } } catch (FileNotFoundException e) { System.err.println("Unable to find the file: fileName"); } catch (IOException e) { System.err.println("Unable to read the file: fileName"); } } }
while( (strLine = br.readLine()) != null){ System.out.println(strLine); }
while( (strLine = br.readLine()) != null){ if( strLine.toLowerCase().contains("Lets C++".toLowerCase()) { System.out.println(strLine); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)