This bit:
{ "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.