import java.io.*;
public class TextEx{
public static void main (String [] args){
try{
new TextEx().f2();
}catch(IOException e){
e.printStackTrace();
}
FileInputStream in= null;
try{
in=new FileInputStream("myFile.txt");
int b;
b=in.read();
while(b!=-1)
{System.out.println((char)b);
b=in.read();
}
}catch(IOException e){
System.out.println(e.getMessage());
}catch(FileNotFoundException e){
e.printStackTrace();
}finally{
try{
in.close();
}catch(IOException e){
e.printStackTrace();
}
}
}
void m(int i) throws ArithmeticException{
if(i==0)
throw new ArithmeticException("被除数为0");
}
void f() throws FileNotFoundException,IOException{
FileInputStream in=new FileInputStream("myfile.txt");
int b;
b=in.read();
while(b!=-1){
System.out.println((char) b);
b=in.read();
}
}
void f2() throws IOException{
f();
}
}
public class TextEx{
public static void main (String [] args){
try{
new TextEx().f2();
}catch(IOException e){
e.printStackTrace();
}
FileInputStream in= null;
try{
in=new FileInputStream("myFile.txt");
int b;
b=in.read();
while(b!=-1)
{System.out.println((char)b);
b=in.read();
}
}catch(IOException e){
System.out.println(e.getMessage());
}catch(FileNotFoundException e){
e.printStackTrace();
}finally{
try{
in.close();
}catch(IOException e){
e.printStackTrace();
}
}
}
void m(int i) throws ArithmeticException{
if(i==0)
throw new ArithmeticException("被除数为0");
}
void f() throws FileNotFoundException,IOException{
FileInputStream in=new FileInputStream("myfile.txt");
int b;
b=in.read();
while(b!=-1){
System.out.println((char) b);
b=in.read();
}
}
void f2() throws IOException{
f();
}
}
e.printStackTrace();
}catch (IOException e) {
System.out.println(e.getMessage());
}如果父类异常放在最前面的话,即使是FileNotFoundException 错误,但是已经被IOException 的catch捕捉
那么catch FileNotFoundException 再去处理当然会说已经被处理