This should count number of lines, words and characters into file.
But it doesn\'t work. From output it shows only 0.
0
Code:
Use Scanner methods:
Scanner
int lines = 0; int words = 0; int chars = 0; while(in.hasNextLine()) { lines++; Scanner lineScanner = new Scanner(in.nextLine()); lineScanner.useDelimiter(" "); while(lineScanner.hasNext()) { words++; chars += lineScanner.next().length(); } }