0

[enter image description here][1]I am trying to do a java program that reads and edits (add/remove/replace) a specific line in a text file. I was thinking of doing it with a switch-case statement for the choices.. for example:

[1] read file --- this shows the whole content [2] add content --- the user will enter a text and it will save it into the text file [3] replace line --- enters line # and shows the content and the user replaces it [4] remove line --- enters line # and removes the content etc...

is it possible to create a text file and make all of these choices into a single java file? I was also thinking that if i will make this using switch case, i will use methods on each choices to perform its tasks. I'm a bit confused about the flow of this program so it would be helpful if you guys can give me steps or tips in making this? I'm quite a noob at this and I really need help

[1]: https://i.stack.imgur.com/On2S7.png --- i was just starting to do this program and this is my idea

NJH
  • 1
  • 1

1 Answers1

0

Yeah its possible i have done the same thing making a School project in c++. Where you can enter the info about the student, and also edit, delete, view, seek the specific content, delete the entire content.

For writing in file

BufferedWriter write = Files.newBufferedWriter(Paths.get(enter path of the file));  

Reading from file

String content = new String(Files.readAllBytes(Paths.get("enter path")));

replacing a specific content java replace specific string in textfile

deleting content How to delete a specific string in a text file?

Community
  • 1
  • 1