previousblock
说明
示例
返回到分块文件集中的上一个分块
返回到分块文件集中的上一个分块,以获取分块信息。
为一组分块创建一个分块文件集 bs
。
folder = {'accidents.mat','airlineResults.mat','census.mat','earth.mat'}
folder = 1x4 cell
{'accidents.mat'} {'airlineResults.mat'} {'census.mat'} {'earth.mat'}
bs = matlab.io.datastore.BlockedFileSet(folder)
bs = BlockedFileSet with properties: NumBlocks: 4 NumBlocksRead: 0 BlockSize: 'file' BlockInfo: BlockInfo for all 4 blocks AlternateFileSystemRoots: {}
获取第一个分块的信息,并将内部指针向前移动一个分块。
blk1 = nextblock(bs)
blk1 = 1x1 BlockInfo Filename FileSize Offset BlockSize ______________________________________________________________________________ ________ ______ _________ "/mathworks/devel/bat/Bdoc23b/build/matlab/toolbox/matlab/demos/accidents.mat" 7343 0 7343
获取第二个分块的信息,并将内部指针向前移动一个分块。
blk2 = nextblock(bs)
blk2 = 1x1 BlockInfo Filename FileSize Offset BlockSize ___________________________________________________________________________________ __________ ______ __________ "/mathworks/devel/bat/Bdoc23b/build/matlab/examples/matlab/data/airlineResults.mat" 1.5042e+05 0 1.5042e+05
再次获取第二个分块的信息,并将内部指针退回到第二个分块。
prev = previousblock(bs)
prev = 1x1 BlockInfo Filename FileSize Offset BlockSize ___________________________________________________________________________________ __________ ______ __________ "/mathworks/devel/bat/Bdoc23b/build/matlab/examples/matlab/data/airlineResults.mat" 1.5042e+05 0 1.5042e+05
输入参数
bs
— 分块文件集
matlab.io.datastore.BlockedFileSet
对象
分块文件集,指定为 matlab.io.datastore.BlockedFileSet
对象。要创建 BlockedFileSet
对象,请参阅 matlab.io.datastore.BlockedFileSet
。
示例: hasPreviousBlock(bs)
输出参数
blkInfo
— 有关分块的信息
BlockInfo
对象
此 属性 为只读。
有关 BlockedFileSet
对象中分块的信息,以 BlockInfo
对象形式返回,具有以下属性:
Filename
-BlockedFileSet
对象中文件的名称。该名称包含文件的完整路径。FileSize
- 文件的大小(以字节为单位)。Offset
- 要读取的文件内的起始偏移量。BlockSize
- 分块的大小(以字节为单位)。
提示
如果尚未从
BlockedFileSet
对象bs
读取任何分块,previousblock
方法将返回错误。为了避免此错误,可将previousblock
与hasPreviousBlock
和reset
结合使用。hasPreviousBlock
方法检查是否仍然存在先前从BlockedFileSet
对象读取过的分块,而reset
方法将内部指针重置到BlockedFileSet
对象的开头。
版本历史记录
在 R2020a 中推出
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)