全屏
Java FileInputStream(String name)构造函数示例
FileInputStream的FileInputStream(String name)构造函数具有以下语法。
public FileInputStream(String name) throws FileNotFoundException
示例
在下面的代码显示如何使用FileInputStream(String name)构造函数。
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);
// read bytes from this stream
int i = fis.read();
// converts integer to character
char c = (char) i;
System.out.print("Character read: " + c);
}
}
分享到:
0评论