逐块读取文件 [英] Reading file chunk by chunk

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

问题描述

我想逐个读取文件.该文件分为几部分,分别存储在不同类型的媒体上.我目前要做的是调用文件的每个单独部分,然后将其合并回原始文件.

I want to read a file piece by piece. The file is split up into several pieces which are stored on different types of media. What I currently do is call each seperate piece of the file and then merge it back to the original file.

问题在于,我需要等到所有块都到达后才能播放/打开文件. 是否有可能在块到达时读取它们,而不是等待它们全部到达.

The issue is that I need to wait until all the chunks arrive before I can play/open the file. Is it possible to read the chunks as they are arriving as opposed to waiting for them to all arrive.

我正在处理媒体文件(电影文件).

I am working on media file (movie file).

推荐答案

您想要的是

what you want is source data line. This is perfect for when your data is too large to hold it in memory at once, so you can start playing it before you receive the entire file. Or if the file never ends.

源数据行的教程中查看

http://docs.oracle. com/javase/6/docs/api/java/io/FileInputStream.html#read

我将使用此FileInputSteam

I would use this FileInputSteam

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

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