简体   繁体   English

"当我尝试从资产文件夹内的文本文件(.txt)中读取值时,“文件名必须以 .xml 结尾”"

[英]'The file name must end with .xml' when i try to read the value from text file(.txt) inside the assets folder

I'm trying to read the value from the text file(.txt), which is inside the assets folder, when I try to rebuild the project, I'm getting this error, how to solve this?我正在尝试从assets文件夹内的文本文件(.txt)中读取值,当我尝试重建项目时,出现此错误,如何解决?

The file name must end with .xml

this is the java code, I'm trying to read the value from the text file,这是java代码,我正在尝试从文本文件中读取值,

         try {

            InputStream is=getAssets().open("english.text");
            int size=is.available();

            byte[] buffer=new byte[size];
            is.read(buffer);
            is.close();
            line=new String(buffer);

        } catch (IOException e) {
            e.printStackTrace();
        }

图像

You have the assets\/<\/code> directory in the wrong place.您将assets\/<\/code>目录放在错误的位置。 It needs to directly under main\/<\/code> , as a peer of java\/<\/code> and res\/<\/code> .它需要直接在main\/<\/code>下,作为java\/<\/code>和res\/<\/code>的对等点。

"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 需要从android studio中assets文件夹中的txt文件中读取 - Need to read from a txt file in the assets folder in android studio 如何从Assets文件夹中读取具有多个段落的文本文件? - How to read a text file with multiple paragraphs from assets folder? 按下按钮时如何从资产文件夹中读取随机文本文件? - How to read a random text file from the assets folder when a button is pressed? 错误:使用.png时文件名必须以.xml或.png结尾 - Error: The file name must end with .xml or .png when using .png 我尝试通过命令行读取txt文件时FileNotFoundException - FileNotFoundException when I try to read txt file via Command Line 如何从资源目录文件夹中的 a.txt 文件中读取? - How do I read from a .txt file inside of a resource directory folder? 如何在Android Studio中高效快速地从资产文件夹逐行读取.txt文件? - How to read .txt file line by line from assets folder efficiently & in a fast way in Android Studio? 从assets文件夹中读取pdf文件 - Read a pdf file from assets folder 尝试从资源文件夹中读取 txt 文件时出现 Java FileNotFoundException - Java FileNotFoundException when trying to read txt file from resources folder 我在资产文件夹中有一个文本文件。 如何从该文本文件访问随机句子? - I have a text file in the assets folder. How can I access a random sentence from that text file?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM