java新手求问
程序代码:
import java.io.*;
class Test4{
public static void main(String args[])throws IOException{
int i;
FileInputStream fin;
try{
fin=new FileInputStream(args[0]);
}catch(FileNotFoundException e){
System.out.println("File not be founded!");
return;
}catch(ArrayIndexOutOfBoundsException e){
System.out.println("Usage:showFile File");
return;
}
do{
i=fin.read();
if(i!=-1){System.out.print((char)i);}
}while(i!=-1);
fin.close();
}//main
}//Test4
为什么会产生错误呢?
:\java>javac Test4.java
Test4.java:4: 不兼容的类型
找到: IOException
需要: java.lang.Throwable
public static void main(String args[])throws IOException{
^
.\IOException.java:15: 不兼容的类型
找到: IOException
需要: java.lang.Throwable
catch(IOException e){
^
.\IOException.java:39: 不兼容的类型
找到: IOException
需要: java.lang.Throwable
catch(IOException e){
[解决办法]