Using the code below, I am trying to make a log for a plugin, though, every time it makes a entry I want it to go below the other entry. Though, when I test it, it writes the second entry but the first entry gets deleted.
if (commandLabel.equalsIgnoreCase("logmeup")) {
entry++;
entry3 = entry * 3;
FileWriter fw= null;
File file =null;
try {
file = new File("playerLog.txt");
if(!file.exists()) {
file.createNewFile();
}
fw = new FileWriter(file);
if (entry == 1) {
fw.write("Name: " + player.getDisplayName() + "\nIP: " + player.getAddress() + "\nLocation: " + player.getLocation() + "\n");
fw.close();
}
else {
while (entryloop < entry3) {
entryloop++;
fw.write(System.getProperty( "line.separator" ));
}
entryloop = 0;
fw.write("Name: " + player.getDisplayName() + "\nIP: " + player.getAddress() + "\nLocation: " + player.getLocation() + "\n");
fw.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}