BlueJ: Program Buffing Problem

Page 1 of 1

2 Replies - 547 Views - Last Post: 07 January 2014 - 07:01 PM Rate Topic: -----

#1 bluejquestioner1213   User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 43
  • Joined: 29-December 13

BlueJ: Program Buffing Problem

Posted 07 January 2014 - 06:55 PM

My hangman program seems to be working now, but my public class buffing is acting funny. For
private static Reader openFile (String filename)
it says that it can't find class reader. How do I fix that error? If it can't be fixed can I just delete the Buffing class from Hangman and have it work a different way?
Thanks.
public class Buffing
{    
     private static boolean temp;
     /////////////////////////////////
     private boolean isKeyboard;


     /** Connect to the disk file with the given name.  If this
      *  cannot be done, connect to the keyboard instead. */

     public Buffin (String filename)
     {    super (openFile (filename));
          isKeyboard = temp;
     }    //======================


     private static Reader openFile (String filename)
     {    try
          {    temp = false;
               return new FileReader (filename);  // IOException here
          }catch (IOException e)
          {    temp = true;
               return new InputStreamReader (System.in);
          }
     }    //======================


     /** Read one line from the file and return it.  
      *  Return null if at the end of the file. */

     public String readLine()
     {    if (isKeyboard)
          {    System.out.print (" input> ");
               System.out.flush();  // flush the output buffer
          }
          try
          {    return super.readLine(); // in BufferedReader
          }catch (IOException e)
          {    System.out.println ("Cannot read from the file");
               return null;
          }
     }    //============
    }



Is This A Good Question/Topic? 0
  • +

Replies To: BlueJ: Program Buffing Problem

#2 jon.kiparsky   User is offline

  • Beginner
  • member icon


Reputation: 12350
  • View blog
  • Posts: 20,984
  • Joined: 19-March 11

Re: BlueJ: Program Buffing Problem

Posted 07 January 2014 - 06:59 PM

Have you imported java.io.Reader?
Was This Post Helpful? 0
  • +
  • -

#3 macosxnerd101   User is offline

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12800
  • View blog
  • Posts: 45,992
  • Joined: 27-December 08

Re: BlueJ: Program Buffing Problem

Posted 07 January 2014 - 07:01 PM

Let's try something new- don't keep spamming your question around the forums. You already have a thread where this question has been asked. You do not need to open multiple threads or necropost on threads to get attention. Your posting patterns are getting a bit over the top, like you're not trying to solve your problems.

Here is where you asked the question and received an answer. Did you not think to read and try ForteGS' response before opening a new thread?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1