fileinputstreamdemo.java
来自「Java网络编程与分布式计算, 主要分析java网络各方面的编程, 提供许多实用」· Java 代码 · 共 43 行
JAVA
43 行
import java.io.*;
// Chapter 4, Listing 1
public class FileInputStreamDemo
{
public static void main(String args[])
{
if (args.length != 1)
{
System.err.println ("Syntax - FileInputStreamDemo file");
return;
}
try
{
// Create an input stream, reading from the specified file
InputStream fileInput = new FileInputStream ( args[0] );
// Read the first byte of data
int data = fileInput.read();
// Repeat : until end of file (EOF) reached
while (data != -1)
{
// Send byte to standard output
System.out.write ( data );
// Read next byte
data = fileInput.read();
}
// Close the file
fileInput.close();
}
catch (IOException ioe)
{
System.err.println ("I/O error - " + ioe);
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?