Convert the unbuffered stream to a buffered stream - Java File Path IO

Java examples for File Path IO:File Stream

Description

Convert the unbuffered stream to a buffered stream

Demo Code

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

public class Main {
  public static void main(String[] args) {
    Path path = Paths.get("C:/folder1/equipment", "test.txt");

    try (InputStream in = Files.newInputStream(path);
        BufferedReader reader = new BufferedReader(new InputStreamReader(in))) {
      String line = null;//from w  w w.j a v  a 2  s  .  c  o  m
      while ((line = reader.readLine()) != null) {
        System.out.println(line);
      }
    } catch (IOException e) {
      System.err.println(e);
    }

  }
}

Result


Related Tutorials