throws 在方法上抛
throw 在方法里抛- public static void main(String[] args) throws FileNotFoundException {
- // TODO Auto-generated method stub
- File f = new File("d:\\a.txt");
- File f1 = new File("d:\\a.txt");
-
- FileReader fr = new FileReader(f);
- try {
- FileWriter fw = new FileWriter(f1);
- int len = 0;
- while ((len = fr.read())!= -1) {
- fw.write(len);
- fw.flush();
- }
- fr.close();
- fw.close();
-
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- throw new NumberFormatException();
- }
- }
复制代码 throw我就随便找了一个抛了出去
|