我想从我的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