BufferedWriter, FileWriter
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?