Help please - urgent (Project due and not done) - Easy answer
Can somebody please teach me how to edit existent files with java? I just need basics like how do you add lines to a file, search lines in a file and delete lines in a file.
If you guys give me a guide i will waste a lot of time i don't have trying to understand it because i am terrible at understanding guides so if you please want to help me just write me out few lines of codes and say how it works.
this is what i use to create new files.
File userFileLog = new File(userFileId);
PrintWriter output2 = new PrintWriter(userFileLog);
so what do i do if the file does exist? I need to add some lines and remove some from that file.
Re: Help please - urgent (Project due and not done) - Easy answer
If the file exists, Java will automatically overwrite it.
If you wish to add lines to an existing file, you could always read it in and then write it back out again.
You can do a similar thing for searching the file. Read it in line by line and search the String for a word or phrase.