Java FileInputStream.skip(long n)方法範例
FileInputStream
的FileInputStream.skip(long n)
方法具有以下語法。
public long skip(long n) throws IOException
在下面的程式碼顯示如何使用FileInputStream.skip(long n)
方法。
import java.io.IOException;
import java.io.FileInputStream;
public class Main {
public static void main(String[] args) throws IOException {
FileInputStream fis = new FileInputStream("C://test.txt");
// skip bytes from file input stream
fis.skip(4); // From: w ww .y IIB A I.C O m
// read bytes from this stream
int i = fis.read();
// converts integer to character
char c = (char) i;
System.out.print("Character read: " + c);
}
}