我想在Android Project中读取文件。但是我的代码无法正常工作。你能帮我吗?
String dosyaAdi = "sozluk.txt";
String satir;
try{
BufferedReader oku = new BufferedReader(new FileReader(dosyaAdi));
satir = oku.readLine();
while (satir != null) {
tvDeneme.setText(satir);
satir = oku.readLine();
}
oku.close();
}
catch (IOException iox){
System.out.println(dosyaAdi+" adli dosya okunamiyor.");
}
最佳答案
将sozluk.txt
放入<your project dir>\assets\sozluk.txt
,并使用以下命令进行访问:
BufferedReader oku = new BufferedReader(new InputStreamReader(getAssets().open(dosyaAdi)));
关于android - 我想在Android Project中读取文件,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/22946756/