Java Path File List nio addNonEmptyLinesFromFile(final ArrayList result, final String path)

Here you can find the source of addNonEmptyLinesFromFile(final ArrayList result, final String path)

Description

add Non Empty Lines From File

License

Open Source License

Declaration

private static void addNonEmptyLinesFromFile(final ArrayList<String> result, final String path)
            throws IOException 

Method Source Code

//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*/
}

Related

  1. anyPathMatcher(final ImmutableList pathMatchers)
  2. archive(Path archive, List targetFiles)
  3. asFileList(Object... paths)
  4. asPathsList(final File[] files)