我使用Andriod Studio开发了一个应用程序,但是在访问我的资产子文件夹时遇到了一些问题。当我尝试访问资产根文件夹中的文件(例如file1)时,就像这样
AssetManager assetMng = getAssets();
InputStream textoInput;
String path = "file1.txt";
try {
textoInput = assetMng.open(path);
BufferedReader r = new BufferedReader(new InputStreamReader(textoInput));
StringBuilder total = new StringBuilder();
String line;
while ((line = r.readLine()) != null) {
total.append(line);
}
} catch (IOException e){
lista.add("Exception: " + e.toString());
e.printStackTrace();
}
我收到文字成功。但是,当我将“ file1.txt”更改为“ sub \ file2.txt”时,我得到的文件未找到执行。
任何人都知道发生了什么事吗?我想念什么吗?
谢谢!
Android基于linux-使用正斜杠而不是反斜杠。所以,sub/file2.txt
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句