1,JDK7前的处理方式:

public class Text01 {public static void main(String[] args) {FileReader fileReader = null;try {fileReader = new FileReader("G:\\xxx");} catch (FileNotFoundException e) {e.printStackTrace();}finally {if (fileReader != null) {try {fileReader.close();} catch (IOException e) {e.printStackTrace();}}}}}
2,JDK7后的处理方式:(推荐)
public class Text01 {public static void main(String[] args) {try (FileWriter fw = new FileWriter("G:\\xxx")) {fw.write("sss");} catch (IOException e) {e.printStackTrace();}}}
