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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

編譯不能通過(guò),哪里的問(wèn)題,和老師講的代碼一樣。。。

package?com.imooc.io;

import?java.io.File;
import?java.io.IOException;

//列出File的一些常用的比如過(guò)濾,遍歷等操作

public?class?FileUtils?{
	
	/**
	?*?列出指定目錄下(包括其子目錄)的所有文件
	?*/
public?static?void?listDirectory(File?dir)throws?IOException(){
	if(!dir.exists()){
		throw?new?IllegalArgumentException("目錄:"+dir+"不存在");
	}
	if(!dir.isDirectory()){
		throw?new?IllegalArgumentException(dir+"不是目錄");
	}
	String[]?filenames?=?dir.list();
	for?(String?string?:?filenames)?{
		System.out.println(string);
	}
}
}
package?com.imooc.io;
import?java.io.File;
import?java.io.IOException;

public?class?Test1?{

	public?static?void?main(String[]?args)?throws?IOException?{
		//?TODO?Auto-generated?method?stub
		FileUtils.listDirectory(new?File("G:\\BaiduYunDownload"));

	}

}
Exception?in?thread?"main"?java.lang.Error:?Unresolved?compilation?problems:?
	Syntax?error?on?token?"throws",?@?expected?after?this?token
	Syntax?error,?insert?"SimpleName"?to?complete?ClassType
	Syntax?error?on?token?"}",?delete?this?token

	at?com.imooc.io.FileUtils.listDirectory(FileUtils.java:13)
	at?com.imooc.io.Test1.main(Test1.java:10)

http://img1.sycdn.imooc.com//56bef92c00013afd05930685.jpg

正在回答

1 回答

Test1 main 方法里加一句FileUtils fu = new FileUtils();

然后再用創(chuàng)造的實(shí)例調(diào)用方法 fu.listDirectory(new?File("G:\\BaiduYunDownload"));

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

gao634209276 提問(wèn)者

謝謝了,不是這個(gè)原因,listDirectory()是靜態(tài)方法可以直接用類名調(diào)用。 我剛把這兩個(gè)代碼刪了重新打了一遍。沒(méi)有那個(gè)問(wèn)題了,昨天不知道什么原因,可能加載錯(cuò)IllegalArgumentException了
2016-02-14 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

編譯不能通過(guò),哪里的問(wèn)題,和老師講的代碼一樣。。。

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

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

幫助反饋 APP下載

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

公眾號(hào)

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