源代码:
import java.io.*;
public class ShowFile
{
public static void main(String args[])throws IOException
{
int a;
FileInputStream f;
try{
f=new FileInputStream(args[0]);
}catch(FileNotFoundException e){
System.out.println("File not Found");
return;
}catch(ArrayIndexOutOfBoundsException e){
System.out.println("Usage:ShowFile File");
return;
}
System.out.print("文件内容是:");
do{
a=f.read();
if(a!=-1)
System.out.print((char)a);
}
while(a!=-1);
f.close();
}
}
运行截图: