import javabook.*;
import java.io.*;

/**
 *  Program TestFileInputStream
 *
 * <p>
 *  A test program to read data from a file using FileInputStream
 */

class TestFileInputStream
{
   public static void main (String[] args) throws IOException
   {
      MainWindow mainWindow   = new MainWindow();
      OutputBox outputBox     = new OutputBox(mainWindow);
      mainWindow.setVisible( true );
      outputBox.setVisible( true );

      //setup file and stream
      File inFile = new File("sample1.data");
      FileInputStream inStream = new FileInputStream(inFile);

      //set up an array to read data in
      int    fileSize  = (int)inFile.length();
      byte[] byteArray = new byte[fileSize];

      //read data in and display them
      inStream.read(byteArray);
      for (int i = 0; i < fileSize; i++) {
         outputBox.printLine(byteArray[i]);
      }

      inStream.close();
   }
}
