Create DataInputStream out of BufferedInputStream : BufferedOutputStream « File « Java Tutorial






import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.EOFException;
import java.io.FileInputStream;
import java.io.IOException;

public class PrimeReader {
  public static void main(String[] arguments) {
    try {
      FileInputStream file = new FileInputStream("400primes.dat");
      BufferedInputStream buff = new BufferedInputStream(file);
      DataInputStream data = new DataInputStream(buff);

      try {
        while (true) {
          int in = data.readInt();
          System.out.print(in + " ");
        }
      } catch (EOFException eof) {
        buff.close();
      }
    } catch (IOException e) {
      System.out.println("Error - " + e.toString());
    }
  }
}








11.19.BufferedOutputStream
11.19.1.BufferedOutputStream
11.19.2.Create DataOutputStream out of BufferedOutputStream
11.19.3.Create DataInputStream out of BufferedInputStream
11.19.4.Write to file using BufferedOutputStream
11.19.5.Write byte array to file using BufferedOutputStream
11.19.6.Write byte to file using BufferedOutputStream
11.19.7.Append string to a text file