gpt4 book ai didi

android - 我想在 Android 项目中读取文件

转载 作者:行者123 更新时间:2023-11-29 21:10:45 27 4
gpt4 key购买 nike

我想在 Android 项目中读取文件。但是我的代码不起作用。你能帮我吗?

            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 项目中读取文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22946756/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com