Source of junk.java


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