package IO;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
public class FileInputStreamTest05 {
public static void main(String[] args) {
FileInputStream fis =null;
try {
fis = new FileInputStream("tempfile");
// 总字节数量
System.out.println("剩下未读字节数:" + fis.available());
// 读一个字节
//int readByte = fis.read();
// 还剩下5个字节
//System.out.println("剩下未读字节数:" + fis.available());
/*byte[] bytes = new byte[fis.available()];
int readCount = fis.read(bytes);
System.out.println(new String(bytes));*/
// skip跳过几个字节不读
fis.skip(3);
System.out.println(fis.read());
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (fis != null) {
try {
fis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
|