我想從我的R.raw文件夾使用inputstream打開文件。但是,我總是得到這個錯誤:從R.raw文件夾打開文件
'The method getResources() is undefined for the type Wordchecker'
,當我試圖用快速解決另一個錯誤appears.like這一個:
'The method openRawResource(int) is undefined for the type Object'...
這裏是我的代碼:
public class Wordchecker {
public static void main(String arg[]){
HashSet <String> newset = new HashSet <String>();
try{
//opening file of words
InputStream is = getResources().openRawResource(R.raw.wordlist);
DataInputStream in = new DataInputStream(is);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
//reading file of words
while ((strLine = br.readLine()) != null) {
newset.add(strLine); //adding word to the hash set newset
}
in.close();
}catch (Exception e){
e.printStackTrace();
}
}
private static Object getResources() {
// TODO Auto-generated method stub
return null;
}
}
謝謝你..我剛剛錯過了... @ Festus Tamakloe – kathy 2013-02-16 09:42:23
@ user2078012不客氣。如果你喜歡我的回答就接受它。謝謝 – 2013-02-16 09:50:38