Java - 按块读取文件块 [英] Java - Reading file chunk by chunk

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

问题描述

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

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

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

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