Results 1 to 5 of 5
  1. #1
    ladykrimson is offline Member
    Join Date
    Oct 2010
    Posts
    69
    Rep Power
    0

    Default BufferedWriter, FileWriter

    Java Code:
    	
    import java.io.BufferedWriter;
    import java.io.File;
    import java.io.FileWriter;
    .......
    .......
    
    public void save(boolean saveagain)
            {
    		try
                    {
    			BufferedWriter w = new BufferedWriter(new FileWriter("c:\\data\\inventory.dat"));
    			for (int i = 0; i < size(); i++)
                            {
                                BlurayDVD dvd = get (i);
                               [COLOR="Red"][SIZE="4"][B] w.write[/B][/SIZE][/COLOR](" %d\t%18s\t%d\t$%.2f\t$%.2f\t$%.2f\t%s\n", dvd.dvdItem, dvd.getDvdTitle(),  dvd.getDvdStock(), dvd.getDvdPrice(), dvd.titleValue(), dvd.getRestockFee(), dvd.getCategory());
                             }
                                w.close();
                    }
                   catch (Exception ex)
                    {
                                if (saveagain)
                                {
    				new File("c:\\data\\").mkdir(); // create the file if it wasn't there!
    				save(false);  // WARNING! IT STILL DON'T WORK!
                                }
    		}
    
              }
    Java is considering the w.write that I have highlighted as a new variable instead of as a new FileWriter. I can't figure out why. Can anyone else see the reason?

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

  3. #3
    ladykrimson is offline Member
    Join Date
    Oct 2010
    Posts
    69
    Rep Power
    0

    Default

    it says:

    cannot find symbol
    symbol: method write(Java.lang.String,int,Java.lang.String,int,do uble,double,double,Java.lang.String)
    location: class java.io.BufferedWriter

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by ladykrimson View Post
    it says:

    cannot find symbol
    symbol: method write(Java.lang.String,int,Java.lang.String,int,do uble,double,double,Java.lang.String)
    location: class java.io.BufferedWriter
    Sorry to be cranky, but as I asked in your last thread from today, please post the error messages without our having to ask you. We can solve this a lot quicker if you don't hide necessary information from us.

    So now that you've given it to us, we can see that the error message is straightforward and says that there is no BufferedWriter write method that takes the parameters that you're passing to it, and if you check the API for BufferedWriter, you'll see that this is correct. Your next step is to use the API to find a method that will work for you, and to pass in the correct parameters.

    Luck.

  5. #5
    ladykrimson is offline Member
    Join Date
    Oct 2010
    Posts
    69
    Rep Power
    0

    Default

    Thank you very much. I am sorry for not posting the error message sooner. I've had a very VERY rough couple of days, so my mind is not all there.

    I will try to do better in the future.

Similar Threads

  1. BufferedWriter
    By Karthika in forum New To Java
    Replies: 6
    Last Post: 04-22-2010, 09:23 AM
  2. Null Pointer Exception with BufferedWriter
    By Sasquatch192 in forum New To Java
    Replies: 3
    Last Post: 10-26-2009, 06:32 PM
  3. FileWriter doesn't write
    By superman5 in forum NetBeans
    Replies: 2
    Last Post: 07-30-2009, 05:46 AM
  4. JAva Filewriter
    By tommyyyy in forum New To Java
    Replies: 1
    Last Post: 03-28-2009, 12:51 PM
  5. Replies: 0
    Last Post: 06-26-2008, 07:33 PM

Posting Permissions

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