package javaapplication5; import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; import java.util.logging.Level; import java.util.logging.Logger; /** * BufferedReader and Scanner can be used to read line by line from any File or * console in Java. * This Java program demonstrate line by line reading using BufferedReader in Java * * @author Javin Paul */ public class BufferedReaderExample { public static void main(String args[]) throws IOException{ //reading file line by line in Java using BufferedReader FileInputStream fis = null; BufferedReader br = null; //String line; try { fis = new FileInputStream("E:/Sum.txt"); br = new BufferedReader(new InputStreamReader(fis)); String line; while((line = br.readLine()) != null){ if(line.contains("/*") || line.contains("*/")|| line.contains("//")){ System.out.println(line); } else System.out.println(""); } br.close(); } catch(IOException e){ System.out.println("file could not read"); } } }
"/*"
"*/"
"//"
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)