Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

number of lines in file java

// Get lines in a file
public int linesInFile(String path) {
	try {
		return (int) Files.lines(Paths.get(path)).count(); // Get lines and convert to integer
	} catch(IOException e) {
		e.printStackTrace(); // Print error if file does not exist.
	}
	return -1; // Return -1, if file does not exist.
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #number #lines #file #java
ADD COMMENT
Topic
Name
7+7 =