开发者

Android: How to update specific line of text file

开发者 https://www.devze.com 2023-03-07 13:41 出处:网络
does anyone has idea on how to code this: I have a text f开发者_开发百科ile with contents (4 lines):

does anyone has idea on how to code this:

I have a text f开发者_开发百科ile with contents (4 lines):

1 I am Kris
2 I live in CA
3 With my wife
4 And son

Then I want to update the second line I live in CA to I live in New York

Is it possible?


The easiest way just to read whole file, modify lines and write back.

You can try RandomAccessFile class, but I think it will be overhead. You'll need to do more work and it will be harder to implement.

0

精彩评论

暂无评论...
验证码 换一张
取 消