home *** CD-ROM | disk | FTP | other *** search
/ Learn Java Now / Learn_Java_Now_Microsoft_1996.iso / JavaNow / Code / Chap10 / IOTest / IOTest.java < prev    next >
Encoding:
Java Source  |  1996-07-02  |  985 b   |  34 lines

  1. import java.io.*;
  2.  
  3. public class IOTest
  4. {
  5.     public static void main(String[] args)
  6.     {
  7.         try
  8.         {
  9.             // let's just try reading from the keyboard
  10.             byte bArray[] = new byte[128];
  11.             System.out.println("Enter something:");
  12.  
  13.             // the following reads in an array of bytes
  14.             System.in.read(bArray);
  15.  
  16.             // output the array of bytes - this generates
  17.             // peculiar results
  18.             System.out.print("You entered:");
  19.             System.out.println(bArray);
  20.  
  21.             // let's investigate
  22.             Class cInClass = System.in.getClass();
  23.             Class cOutClass= System.out.getClass();
  24.             System.out.println("in is " + cInClass.toString());
  25.             System.out.println("out is " + cOutClass.toString());
  26.         }
  27.         catch(IOException ioe)
  28.         {
  29.             System.out.println(ioe.toString());
  30.             ioe.printStackTrace();
  31.         }
  32.     }
  33. }
  34.