第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定

為何createNewFile無法創(chuàng)建文件?

public?static?void?main(String[]?args)?{
		File?file=new?File("resources");
		if(!file.exists()){
			file.mkdir();
		System.out.println("ok");}
		System.out.println(file.getAbsolutePath());
		File?file2=new?File(file,"one.dat");
		if(!file2.exists()){
			try{
			file.createNewFile();
			System.out.println("file2?created");
			}
			catch?(IOException?e){
				System.out.println("error");
			}
			System.out.println(file2.getAbsolutePath());}
		System.out.println(file2.exists());
	}
	
	經(jīng)查硬盤,創(chuàng)建了resources文件夾,但并沒有創(chuàng)建one.dat,并且輸出結(jié)果是:
	E:\javaProject\demo\resources
????????file2?created
????????E:\javaProject\demo\resources\one.dat
????????false
????????
????????java的getAbsolutePath可以獲取one.dat的路徑,但是exists卻判斷one.dat不存在(確實也不存在)
????????
????????請問問題出在哪里,我該如何解決?


正在回答

1 回答

file.createNewFile();這里你要寫file2.createNewFile()才對啊

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

好鬼過癮 提問者

非常感謝!
2015-09-28 回復(fù) 有任何疑惑可以回復(fù)我~

舉報

0/150
提交
取消

為何createNewFile無法創(chuàng)建文件?

我要回答 關(guān)注問題
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號