Search code examples
javaandroidinputstream

'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?

The file name must end with .xml

this is the java code, I'm trying to read the value from the text file,

         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();
        }

img


Solution

  • You have the assets/ directory in the wrong place. It needs to directly under main/, as a peer of java/ and res/.