我真的不明白我怎么能创建这样的输入流,这是寻找和定位可读。。。
Resource resource = new ClassPathResource("somefile");
InputStream bla = resource.getInputStream();
FSDataInputStream inputStream = new FSDataInputStream (bla);
在fs线上投掷:
java.lang.IllegalArgumentException: In is not an instance of Seekable or PositionedReadable
我需要模仿,这对我来说是个障碍。
1条答案
按热度按时间vktxenjb1#
FSDataInputStream
在fsdatainputstream.java中定义的构造函数,如下所示InputStream
参数为instance
的Seekable
或者PositionedReadable
```public FSDataInputStream(InputStream in) throws IOException
{
super(in);
if( !(in instanceof Seekable) || !(in instanceof PositionedReadable) ) {
throw new IllegalArgumentException(
"In is not an instance of Seekable or PositionedReadable");
}
}
import java.io.*;
import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.fs.PositionedReadable;
import org.apache.hadoop.fs.Seekable;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
public class SeekableTest {
}