开发者

How to read very large file i.e 100MB as String

My large_file.txt contains <tag> to represent data such as parents, childs and so on. My large_file.txt format is 开发者_JAVA百科not xml format.

I want to read large_file.txt size 100 MB as a one string, then using String matching to get my data as a object.

Any help please?

Thanks in advance


I want to read large_file.txt size 100 MB as a one string

You really don't want to do that. You want to do anything you can to avoid it. You should always aim to process files a piece at a time. What happens when the file gets 10 times the size? 100? 1000?


http://bytes.com/topic/java/answers/17999-regex-whole-large-text-file


You can use Jakarta Regexp's StreamCharacterIterator. This way you can directly apply string matching on the file without reading it first into a String object.

Otherwise you can use Commons IO's FileUtils.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜