我正在尝试使用输入流从我的 R.raw 文件夹中打开文件。但我总是得到这个错误:
'The method getResources() is undefined for the type Wordchecker'
当我尝试使用快速修复时,出现另一个错误。就像这个:
'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;
}
}