Read from file in Path type with buffered reader - Java File Path IO

Java examples for File Path IO:Path

Description

Read from file in Path type with buffered reader

Demo Code

import java.io.BufferedReader;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;

public class Main {
  public static void main(String[] args) {
    Path path = null;//from ww  w .  ja  va  2  s.  c  o  m
    
    try (BufferedReader inputReader = Files.newBufferedReader(path, Charset.defaultCharset())) {
      String inputLine;
      while ((inputLine = inputReader.readLine()) != null) {
        System.out.println(inputLine);
      }
    } catch (IOException ex) {
      ex.printStackTrace();
    }

  }
}

Related Tutorials