Source of junk.java


  1: 
  2: import java.io.*;
  3: import java.util.*;
  4: 
  5: public class junk
  6: {
  7:     public static void main(String[] args)
  8:     {
  9:        try
 10:        {
 11:            BufferedReader inputStream =
 12:                new BufferedReader(new FileReader("data.txt"));
 13: 
 14:            String line = null;
 15:            line = inputStream.readLine( );
 16:            System.out.println("The first line in data.txt is:");
 17: 
 18:            System.out.println(line);
 19:            line = inputStream.readLine( );
 20:            System.out.println("The second line in data.txt is:");
 21:            System.out.println(line);
 22:            inputStream.close( );
 23:        }
 24:        catch(FileNotFoundException e)
 25:        {
 26:            System.out.println("File data.txt was not found");
 27:            System.out.println("or could not be opened.");
 28:        }
 29:        catch(IOException e)
 30:        {
 31:            System.out.println("Error reading from file data.txt.");
 32:        }
 33:     }
 34: 
 35:     //This method does do not what we want it to do.
 36:         public static void openFile(ObjectOutputStream streamName)
 37:                                                   throws IOException
 38:         {
 39:             System.out.println("Enter file name:");
 40:             Scanner keyboard = Scanner.create(System.in);
 41:             String fileName = keyboard.next( );
 42:             streamName =
 43:                   new ObjectOutputStream(
 44:                          new FileOutputStream(fileName));
 45: }
 46: }