```java
package com.gosuncn;
import java.io.FileInputStream;
import java.io.IOException;
public class JavaIOInputStream {
public static final String SOURCE_FILENAME = "C:\\Users\\Administrator\\Desktop\\UTF8.txt";
public static void main(String[] args) throws Exception {
markSupported(new FileInputStream(SOURCE_FILENAME));
}
public static void read1(FileInputStream inputStream) throws IOException {
int data = inputStream.read(); // 用int接收一個byte數據,若data=-1則文件讀取完畢
}
public static void read2(FileInputStream inputStream) throws IOException {
byte[] buffer = new byte[1024];
int len = inputStream.read(buffer); // len表示讀取字節的長度,若len=-1則文件讀取完畢
}
public static void read3(FileInputStream inputStream) throws IOException {
byte[] buffer = new byte[1024];
/**
* len 表示讀取字節的長度,若 len=-1 則文件讀取完畢.
* off 表示在向 buffer 中存數據時,偏移的字節數.
* len 表示在向 buffer 中存數據時,存放的字節數(Java根據len從流中讀取一定數量的字節).
*/
int len = inputStream.read(buffer, 2, 1);
}
public static void skip(FileInputStream inputStream) throws IOException {
long skip = inputStream.skip(9L); // 跳過指定字節數,底層指針往下移動指定字節數.
}
public static void available(FileInputStream inputStream) throws IOException {
int available = inputStream.available(); // 返回可讀的字節數量
}
public static void close(FileInputStream inputStream) throws IOException {
inputStream.close(); // 關閉流
}
public static void markSupported(FileInputStream inputStream) {
/**
* 查詢是否支持標記
* 如果支持標記,可以通過mark(int)方法進行標記.
* 標記成功以后,可以通過reset()方法返回上次標記位置.
*/
boolean markSupported = inputStream.markSupported();
}
}
```