home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 39 / IOPROG_39.ISO / SOFT / sdkjava40.exe / data1.cab / fg_Samples / Samples / Security / loader / FileReader.java < prev    next >
Encoding:
Java Source  |  2000-05-04  |  862 b   |  40 lines

  1. // FileReader.java
  2. //
  3. // Created 09/12/97
  4. //
  5. // (C) Copyright 1995 - 1999 Microsoft Corporation.  All rights reserved.
  6. //
  7.  
  8. import java.io.*;
  9.  
  10.  
  11. public class FileReader
  12. {
  13.     public static void main (String[] args)
  14.     {
  15.         for (int i = 0; i < args.length; i++)
  16.         {
  17.             tryfile(args[i]);
  18.         }
  19.     }
  20.  
  21.     static void tryfile (String filename)
  22.     {
  23.         System.out.print(filename+": "); System.out.flush();
  24.         try
  25.         {
  26.             FileInputStream fis = new FileInputStream(filename);
  27.             System.out.print("opened: "); System.out.flush();
  28.             DataInputStream dis = new DataInputStream(fis);
  29.             String line = dis.readLine();
  30.             System.out.println(line);
  31.         }
  32.         catch (Throwable e)
  33.         {
  34.             System.out.println(e);
  35.         }
  36.     }
  37. }
  38.  
  39.  
  40.