我如何读取大文件 [英] How can i read a large file

查看:63
本文介绍了我如何读取大文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想读取一个大小大于等于500 MB的文件,我想将其转换为字节流并将其作为二进制文件写入.

I want to read a file of size >= 500 MB and i want to convert it to byte stream and write it as a binary file

推荐答案

您可以在这里使用多线程.不建议读取整个文件,因为这会非常慢,因此请为每个线程创建缓冲区以存储文件的各个部分.线程将从分配的缓冲区中读取并进行必要的操作.
这是一个有意义的简短答案: http://stackoverflow.com/questions/3197187/multithreaded-file-writing [ ^ ].

希望对您有所帮助.
You can use multithreading here. Reading the whole file is not recommended as it will be very slow, hence create buffers for each thread to store sections of the file. The threads will read from the assigned buffers and do the necessary operation.
Here is one brief answer which makes sense: http://stackoverflow.com/questions/3197187/multithreaded-file-writing[^].

Hope it helped.


这篇关于我如何读取大文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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