Thread: java IO
View Single Post
  #2 (permalink)  
Old 12-11-2007, 01:03 AM
dmacvittie dmacvittie is offline
Member
 
Join Date: Aug 2007
Posts: 30
dmacvittie is on a distinguished road
This bit:
Quote:
{ "Head First Java", "Bates and Sierra", "2003" },
{ "Thinking In Java", "Bruce Eckel", "2002" },
{ "Learning Java", "Niemeyer and Knudsen", "2000" },
{ "Developing Java Sortware", "Winder and Roberts", "2000" }
};
File file = new File("gramata3.txt");
try {
PrintWriter out = new PrintWriter(
new FileWriter(file));
for(int j = 0; j < books.length; j++) {
out.println(books[j][2] + " " + books[j][0] + " by " + books[j][1]);
}
out.close();
} catch(IOException e) {
System.out.println("write error: " + e.getMessage());
}
Would over-write your file every time. Run the program once, then comment out those lines and run it again. All should go well for you.

Don.
__________________
Don MacVittie F5 Networks -
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Reply With Quote