I would like to know if it's possible to add a line in a File with Java.
For example myFile :
1: line 1
2: line 2
3: line 3
4: line 4
I would like to add a line fox example in the third line so it would look like this
1: line 1
2: line 2
3: new line
4: line 3
5: line 4
I found out how to add text in an empty file or at the end of the file but i don't know how to do it in the middle of the text without erasing the line.
Is the another way than to cut the first file in 2 parts and then create a file add the first part the new line then the second part because that feels a bit extreme ?
Thank you