Results 1 to 7 of 7
  1. #1
    niu_niu is offline Member
    Join Date
    Jun 2010
    Posts
    48
    Rep Power
    0

    Default Sinking into a swamp called "BufferedReader"...SOS...

    Java Code:
    import java.io.*; 
    import acm.program.*;
    import java.util.*;
    import acm.util.*;
    
    
    public class myReader extends ConsoleProgram {
    	public void run( ) {
    
    		println(" this program reverse the lines in a file. "); 
    		BufferedReader rd = new openFileReader("Enter input file: ");
    		String[ ] lines = readLineArray(rd); 
    		for (int i=lines.length-1; i >=0; i--) {
    			println(lines[i]); 
    		}		
    	}
    }
    Question:
    I am getting an error on the line

    BufferedReader rd = new openFileReader("Enter input file: ");

    The error message says: "openFileReader" cannot be resolved to a type.

    I can't figure out what I am missing here.

    Please pull me out of the swamp?

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default

    BufferedReader rd = new openFileReader("Enter input file: ");
    Where is the class: openFileReader defined? The compiler can't find it.

  3. #3
    niu_niu is offline Member
    Join Date
    Jun 2010
    Posts
    48
    Rep Power
    0

    Default

    I thought all those "import" lines should have taken care of that. so what package or class should I import then?

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,439
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by niu_niu View Post
    I thought all those "import" lines should have taken care of that. so what package or class should I import then?
    AFAIK there is no openFileReader class in the code SE distribrution.

    kind regards,

    Jos

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default

    Where did you get openFileReader from?
    Why did you put it in your program?

    When all else fails, read the API doc.

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,949
    Rep Power
    19

    Default

    You use "new" which implies to the compiler that the thing following the "new" is a class, in this case openFileReader.

    I suspect you actually mean this to be a method? In which case drop the "new" and, well, write the method?

  7. #7
    niu_niu is offline Member
    Join Date
    Jun 2010
    Posts
    48
    Rep Power
    0

Similar Threads

  1. Replies: 1
    Last Post: 01-21-2010, 09:20 AM
  2. problem with argument list and precedence "(" and ")"
    By helpisontheway in forum Advanced Java
    Replies: 6
    Last Post: 12-24-2009, 07:50 AM
  3. Replies: 2
    Last Post: 10-08-2009, 11:28 PM
  4. Replies: 2
    Last Post: 01-24-2009, 06:56 PM
  5. Replies: 1
    Last Post: 10-20-2008, 07:35 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •