这是添加了throws子句的openFile方法:
/** 来 自 时代Java - N o w J a v a . c o m **/ import java.io.FileInputStream; import java.io.FileNotFoundException; public class Main { public static void main(String[] args) { try { openFile("C:/test.txt"); } catch (FileNotFoundException e) { System.out.println("File not found."); } } /* *来 自 时代Java公众号 */ public static void openFile(String name)