Java - Load file, replace string, save

前端 未结 3 619
借酒劲吻你
借酒劲吻你 2021-01-24 09:07

I have a program that loads lines from a user file, then selects the last part of the String (which would be an int)

Here\'s the style it\'s saved in:

na         


        
3条回答
  •  感情败类
    2021-01-24 09:30

    I think most convenient way is:

    1. Read text file line by line using BufferedReader
    2. For each line find the int part using regular expression and replace it with your new value.
    3. Create a new file with the newly created text lines.
    4. Delete source file and rename your new created file.

    Please let me know if you need the Java program implemented above algorithm.

提交回复
热议问题