Write a Java program that displays the number of characters, lines and words in a text?

import java.io.*;
class CountFile {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new FileReader("test.txt"));
        int chars=0, words=0, lines=0;
        String line;
        while ((line=br.readLine())!=null) {
            lines++;
            chars += line.length();
            words += line.split("\\s+").length;
        }
        System.out.println("Lines="+lines+" Words="+words+" Chars="+chars);
        br.close();
    }
}