Read from file with BufferedInputStream : BufferedInputStream « File « Java Tutorial






import java.io.BufferedInputStream;
import java.io.FileInputStream;

public class Main {
  public static void main(String[] args) throws Exception {
    byte[] buffer = new byte[1024];
    BufferedInputStream bufferedInput = new BufferedInputStream(new FileInputStream("filename.txt"));

    int bytesRead = 0;
    while ((bytesRead = bufferedInput.read(buffer)) != -1) {
      String chunk = new String(buffer, 0, bytesRead);
      System.out.print(chunk);
    }
    bufferedInput.close();
  }
}








11.9.BufferedInputStream
11.9.1.BufferedInputStream
11.9.2.Buffered Stream Copier
11.9.3.Read from file with BufferedInputStream
11.9.4.Read File in String Using Java BufferedInputStream Example
11.9.5.Read File Using Java BufferedInputStream Example
11.9.6.Use buffered streams to copy a file
11.9.7.Import a file of exported preference data.
11.9.8.Save keyboard input with BufferedInputStream