나는 사전의 텍스트 파일을 갖고 있으며 단어를 EditText
값과 일치시키고 싶습니다. 하지만 다음과 같은 오류가 나타납니다. java.io.FileNotFoundException: /Test/res/raw/test.txt: open failed: ENOENT (No such file or directory)
텍스트 파일을 열 수 없습니다.
여기까지 내가 한 것입니다.
public void show(View view) throws IOException
{
File file = new File("/Test/res/raw/test.txt");
if (!file.exists())
{
helloTxt1.setText("empty");
}
try
{
FileInputStream in = new FileInputStream(file);
int len = 0;
byte[] data1 = new byte[1024];
while (-1 != (len = in.read(data1)))
{
if(new String(data1, 0, len).contains(edittxt.getText().toString()))
{
helloTxt1.setText("1");
}
else
{
helloTxt1.setText("0");
}
}
} catch (FileNotFoundException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
미리 감사드립니다. 당신이 당신의 입술 폴더 내에서 원시 폴더를 만든 것처럼
도움이 되셨습니까? (http://stackoverflow.com/questions/2856407/android-how-to-get-access-to-raw-resources-that-i-put-in-res-folder) –
하드 코드 된 경로를 사용하지 마십시오! :) – RvdK