FileInputStream

来源:互联网 发布:软件测试的基本原理 编辑:程序博客网 时间:2024/04/29 05:56

FileINputStream
FileInputStream,:This stream is not buffered. Most callers should wrap this stream with aBufferedInputStream.
这个流不缓冲,绝大多数情况下使用BufferedInputStream来包装
比如读取一个文件Flie sdCardDir=Environment.getExternalStorageDirectonry();

1)构造器
ileInputStream(File file)
Constructs a new FileInputStream that reads from file.

FileInputStream(FileDescriptor fd)//可以补考虑
Constructs a new FileInputStream that reads from fd.

FileInputStream(String path)//根据文件路径获取对应的流
Equivalent to new FileInputStream(new File(path)).
2)方法intavailable()
Returns an estimated number of bytes that can be read or skipped without blocking for more input.
voidclose()
Closes this stream.
intread()
Reads a single byte from this stream and returns it as an integer in the range from 0 to 255.
intread(byte[] buffer, int byteOffset, int byteCount)
Reads up to byteCount bytes from this stream and stores them in the byte arraybuffer starting at byteOffset.
longskip(long byteCount)
Skips at most n bytes in this stream.




0 0
原创粉丝点击