package cm;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
public class test20180422FileInputStream {
public static void main(String[] args) throws FileNotFoundException {
//继承自类Inputstream
File f=new File("D:\\");
FileInputStream fis=new FileInputStream(f);
try {
fis.read();//从此输入流中读取一个数据字节。如果没有输入可用,则此方法将阻塞。
byte[]b=new byte[4];
fis.read(b);//从此输入流中将最多 len 个字节的数据读入一个 byte 数组中。如果 len 不为 0,则在输入可用之前,该方法将阻塞;否则,不读取任何字节并返回 0。
fis.skip(3L);//从输入流中跳过并丢弃 n 个字节的数据, 出于各种原因,skip 方法最终跳过的字节数可能更少一些,甚至可能为 0。如果 n 为负,则抛出 IOException,
} catch (IOException e) {
e.printStackTrace();
}
}
}
FileInputStream
最新推荐文章于 2025-04-11 18:05:37 发布