I have a text file that needs editing every time a jar runs. Here is what it initially looks like.
1.png
2.png
3.png
4.png
What I've been trying to do is use FileWriter to move the top line to the bottom, so the next line will be on top, so the result would be.
2.png
3.png
4.png
1.png
Here is the code I wrote so far:
BufferedReader reader = new BufferedReader(new FileReader("list.txt"));
FileWriter writer = new FileWriter("list.txt");
String newName = scan.nextLine();
writer.write(newName);
reader.close();
writer.close();
This won't work because the only thing present in the text will be png.2
. So I was wondering... is there a way to tell FileWriter or something else to simply move the first line to the bottom?