Java Path File Read nio readAndConsume(String filePath, Consumer consumer)

Here you can find the source of readAndConsume(String filePath, Consumer consumer)

Description

read And Consume

License

Apache License

Declaration

static void readAndConsume(String filePath, Consumer<String> consumer) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.function.Consumer;
import java.util.stream.Stream;

public class Main {
    static void readAndConsume(String filePath, Consumer<String> consumer) throws IOException {
        Stream<String> lines = null;
        lines = Files.lines(Paths.get(filePath));
        lines.forEach(consumer);/*from www  .j a  v  a2  s  .  c  o m*/
    }
}

Related

  1. read(String filePath)
  2. read(String path)
  3. readAllLines(Path path)
  4. readAllLines(String path)
  5. readAllLinesOrExit(Path path)
  6. readAsString(Path path)
  7. readAsString(String path)
  8. reader(String path)
  9. readers(String path)