I am working with java. I want to work with a text file which is given to me by command line arguments. Now I need to count the lines in the file and work more closely with its content. How is that possible?
If you want to count lines in the file you must use BufferedReader
or Scanner
classes, they have readLine()
method and all want you do is read line by line in cycle while line is not null and add them to ArrayList<String>
in same time, after cycle done you have list with your text and his size is count of lines in the text.