Here you can find the source of addNonEmptyLinesFromFile(final ArrayList
private static void addNonEmptyLinesFromFile(final ArrayList<String> result, final String path) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.IOException; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; public class Main { private static void addNonEmptyLinesFromFile(final ArrayList<String> result, final String path) throws IOException { final List<String> lines = Files.readAllLines(Paths.get(path), StandardCharsets.UTF_8); lines.stream().filter(s -> s.length() > 0).forEach(result::add); }/*from w w w. j av a2 s . c o m*/ }