Results 1 to 5 of 5
Thread: BufferedWriter, FileWriter
- 12-06-2010, 01:48 AM #1
Member
- Join Date
- Oct 2010
- Posts
- 68
- Rep Power
- 0
BufferedWriter, FileWriter
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?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! } } }
-
- 12-06-2010, 02:07 AM #3
Member
- Join Date
- Oct 2010
- Posts
- 68
- Rep Power
- 0
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.
- 12-06-2010, 02:35 AM #5
Member
- Join Date
- Oct 2010
- Posts
- 68
- Rep Power
- 0
Similar Threads
-
BufferedWriter
By Karthika in forum New To JavaReplies: 6Last Post: 04-22-2010, 09:23 AM -
Null Pointer Exception with BufferedWriter
By Sasquatch192 in forum New To JavaReplies: 3Last Post: 10-26-2009, 06:32 PM -
FileWriter doesn't write
By superman5 in forum NetBeansReplies: 2Last Post: 07-30-2009, 05:46 AM -
JAva Filewriter
By tommyyyy in forum New To JavaReplies: 1Last Post: 03-28-2009, 12:51 PM -
How to use BufferedWriter and BufferedReader with PipedWriter and PipedReader
By Java Tip in forum java.ioReplies: 0Last Post: 06-26-2008, 07:33 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks