為什么創(chuàng)建不了文件
?? ??? ?File file2 = new File("C:\\Users\\濤某\\Desktop\\日常文件\\日記1.txt");
?? ??? ?if (!file2.exists()) {
?? ??? ??? ?try {
?? ??? ??? ??? ?file.createNewFile();
?? ??? ??? ?} catch (IOException e) {
?? ??? ??? ??? ?// TODO 自動(dòng)生成的 catch 塊
?? ??? ??? ??? ?e.printStackTrace();
?? ??? ??? ?}
?? ??? ?}else {
?? ??? ??? ?file2.delete();
?? ??? ?}
2019-05-16
因?yàn)槟阄募淮嬖跁r(shí),創(chuàng)建了新文件。存在時(shí)調(diào)用了delete會(huì)刪除已存在文件,所以沒(méi)有文件