Here you can find the source of getNumberOfNonEmptyLines(File file, Charset charset)
public static int getNumberOfNonEmptyLines(File file, Charset charset) throws IOException
//package com.java2s; //License from project: LGPL import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.nio.charset.Charset; public class Main { public static int getNumberOfNonEmptyLines(File file, Charset charset) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), charset)); try {/*www . j av a2s. c o m*/ int count = 0; String line; while ((line = reader.readLine()) != null) if (!line.isEmpty()) ++count; return count; } finally { reader.close(); } } }