home *** CD-ROM | disk | FTP | other *** search
/ Java by Example / jbecd.bin / JBE-CD / NTUsers / JBECODE.ZIP / JavaByExample / chap36 / FileApp.java < prev    next >
Text File  |  1996-03-25  |  909b  |  39 lines

  1. import java.io.*;
  2.  
  3. public class FileApp
  4. {
  5.     public static void main(String args[])
  6.     {
  7.         System.out.println("");
  8.         System.out.println("------------------------------");
  9.         System.out.println("");
  10.  
  11.         try
  12.         {
  13.             FileInputStream inputStream =
  14.                 new FileInputStream("test.java");
  15.  
  16.             String str = "";
  17.             int b = 0;
  18.             while(b != -1)
  19.             {
  20.                 b = inputStream.read();
  21.                 str += (char)b;
  22.             }
  23.  
  24.             inputStream.close();
  25.             System.out.println(str);
  26.         }
  27.         catch (FileNotFoundException e)
  28.         {
  29.             System.out.println("File not found!");
  30.         }
  31.         catch (IOException e)
  32.         {
  33.             System.out.println("I/O Error!");
  34.         }
  35.  
  36.         System.out.println("------------------------------");
  37.     }
  38. }
  39.