read and write file

dog 2003-07-01 06:17:53
有2个文件,要合并。
test1.txt
a
b
c
///////////////////////
test2.txt
a
salary
100

b
salary
1000

c
salary
23
////////////////////////
得到新的test1.txt
a
100
b
1000
c
23
有没有好的算法,我的是先读test1.txt一行得到a,找test2.txt中的a和它的值,写入临时文件,再重复读test1.txt到完,将临时文件写回test1.txt。
...全文
15 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
newman0708 2003-07-01
  • 打赏
  • 举报
回复
能把文件内容写成下面这种吗?

test1.txt
a
b
c
///////////////////////
test2.txt
a
salary=100

b
salary=1000

c
salary=23

这样你就可以ResourceBundle来做了。

参见:
http://expert.csdn.net/Expert/topic/1973/1973694.xml?temp=.5847589
newman0708 2003-07-01
  • 打赏
  • 举报
回复
能把文件内容写成下面这种吗?

test1.txt
a
b
c
///////////////////////
test2.txt
a
salary=100

b
salary=1000

c
salary=23


这样你就可以boudleresource来做了。
loveisbug 2003-07-01
  • 打赏
  • 举报
回复
读test2,放到一个链表里,读test1,从前一个链表得到新链表,再写test1。

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧