to{}catch{}
try{}catch{}的流传输
try {
fis = new FileInputStream("file-APP\\fos.txt");
fos = new FileOutputStream("fos.txt");
int a ;
while ((a= fis.read())!= -1){
fos.write(a);
}
System.out.println(a);
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (fis != null) {
fis.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
try(){}catch{}的流传输 省略close()
try{}catch{}finally{}
finalize()方法*
Objects的equals()方法*
抛异常
自己怎么创建异常 抛异常
创建异常类 重载所有构造方法
class StudentAgeIllegalException extends Exception {
public StudentAgeIllegalException() {
}
public StudentAgeIllegalException(String message) {
super(message);
}
public StudentAgeIllegalException(String message, Throwable cause) {
super(message, cause);
}
public StudentAgeIllegalException(Throwable cause) {
super(cause);
}
public StudentAgeIllegalException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
}
创建异常类对象
抛出异常