本來要先看BufferedFSInputStream的,但是它實現了Seekable和PositionedReadable接口,就先看這兩個,再看它會比較容易理解些
1 package org.apache.hadoop.fs; 2 3 import java.io.*; 4 5 /** Stream that permits seeking. */ 6 //提供按位置查找功能的接口 7 public interface Seekable { 8 /** 9 * Seek to the given offset from the start of the file.10 * The next read() will be from that location. Can't11 * seek past the end of the file.12 */13 void seek(long pos) throws IOException;14 //從指定文件中的位置pos,對文件流進行前向搜索。15 /**16 * Return the current offset from the start of the file17 */18 long getPos() throws IOException;19 //返回文件流中當前偏移位置。 20 /**21 * Seeks a different copy of the data. Returns true if 22 * found a new source, false otherwise.23 */24 boolean seekToNewSource(long targetPos) throws IOException;25 //從targetPos位置搜索文件數據的一個不同拷貝,搜索到則返回true,否則返回false。26 }
新聞熱點
疑難解答