0
import java.io.*;
public class NumberOfLine{
public static void main(String[] args) {
try{
System.out.println();
System.out.println("Getting line number of a paritcular file example!");
System.out.println("***************************************************************");
System.out.println();
// FileInputStream fstream = new FileInputStream("F://Inputfile.txt");
// DataInputStream in = new DataInputStream(fstream);
// System.out.println();
// BufferedReader bf = new BufferedReader(new InputStreamReader(in));
// String strLine;
FileInputStream fstream = new FileInputStream("F://Inputfile.txt");
BufferedReader bf = new BufferedReader(new InputStreamReader(fstream));
DataInputStream in = new DataInputStream(fstream);
// System.out.println("Please enter file name (location) with extension:");
String str = bf.readLine();
File file = new File(str);
if (file.exists()){
FileReader fr = new FileReader(file);
LineNumberReader ln = new LineNumberReader(fr);
int count = 0;
while (ln.readLine() != null){
count++;
}
System.out.println("Total line no: " + count);
ln.close();
}
else{
System.out.println("File does not exists!");
}
}
catch(IOException e){
e.printStackTrace();
}
}
}
ここに質問はありません。あなたは正確に何を知りたいですか? –