Java - Load file, replace string, save

前端 未结 3 649
借酒劲吻你
借酒劲吻你 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:26

    Hard to answer without the complete code...

    Is value a string ? If so the replace will create a new string but you are not saving this string anywhere. Remember Strings in Java are immutable.

    You say you use a BufferedWriter, did you flush and close it ? This is often a cause of values mysteriously disappearing when they should be there. This exactly why Java has a finally keyword.

    Also difficult to answer without more details on your problem, what exactly are you trying to acheive ? There may be simpler ways to do this that are already there.

提交回复
热议问题