替换文件中特定文本行的特定部分 [英] replacing a specific part of a specific line of text inside a file

查看:80
本文介绍了替换文件中特定文本行的特定部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,伙计们,所以标题完全解释了我的目标。事实是我将从xml文件中读取大量数据。这个文件太大了,并没有太多的数据要存储在arraylists而不会耗尽内存,所以我正在阅读,因为我正在阅读我要写一个文件。


这是事情,我已经可以做到这一点并完成它,但我想修改程序,以便您可以选择要取出的数据。为此,我将设置文本文件以显示如下内容:

Alright guys, so the title explains exactly my goal. The truth is I''m going to be reading in a lot of data from an xml file. The file is too large and there''s too much data to store in arraylists without running out of memory, so I''m reading and as I''m reading I''m going to write to a file.

This is the thing though, I already can do this and have it done, but I want to modify the program so you can choose what data you want to take out. To do this I would set up the text file to show something like this:

展开 | 选择 | Wrap | 行号

推荐答案

首先,有许多不同的XML解析器。

- 将整个文件加载到内存中的文件(对大文件不好)

- 那些走XML的人-file从上到下(我认为访客模式)

也许SAX-parser,如果我没有弄错


也许使用另一个XML-解析器首先解决了你的问题。


其次我会做的像这样的东西:
First, there are many different XML-parsers.
- Those which load the complete file into memory (bad for big files)
- Those which walk the XML-file from top to bottom (Visitor-Pattern i think)
maybe SAX-parser, if i''m not mistaken

Maybe using another XML-parser solves your problem in the first place.

Second i would do something like this:
展开 | 选择 < span class =codeDivider> | Wrap | 行号


我会说使用一个包含两列的表来使用(关系)数据库: primary

key(one,two; "三"等)和第二列只包含

文本(1,2,3,4,5等)。


它然后很容易更新/删除/插入数据,当你必须阅读

中的数据时,你可以在第二列上进行处理。使用纯文本文件是一个无法管理的负担(正如你已经勾画过的那样)。


亲切的问候,


Jos
I''d say use a (relational) database using one table with two columns: the primary
key ("one", "two" "three" etc.) and a second column that simply contains the
text ("1, 2, 3, 4, 5" etc.).

It''ll be easy to update/delete/insert data then and when you have to read data in
you could do the processing on that second column. Using plain text files is an
unmanageable burden (as you already sketched).

kind regards,

Jos



我会说使用一个有两列的表来使用(关系)数据库:主要的

key(one,two,three等)和仅包含

文本的第二列(1,2,3,4,5等)等等。


然后更新/删除/插入数据会很容易,当你必须阅读

中的数据时,你可以做到处理第二列。使用纯文本文件是一个无法管理的负担(正如你已经勾画过的那样)。


亲切的问候,


Jos
I''d say use a (relational) database using one table with two columns: the primary
key ("one", "two" "three" etc.) and a second column that simply contains the
text ("1, 2, 3, 4, 5" etc.).

It''ll be easy to update/delete/insert data then and when you have to read data in
you could do the processing on that second column. Using plain text files is an
unmanageable burden (as you already sketched).

kind regards,

Jos



看起来我会查看数据库然后(关系)。谢谢...


-blaze

Looks like I''ll be looking into databases then (relational). Thank you...

-blaze


这篇关于替换文件中特定文本行的特定部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆