Home > Mobile >  'The file name must end with .xml' when i try to read the value from text file(.txt) insid
'The file name must end with .xml' when i try to read the value from text file(.txt) insid

Time:02-07

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

CodePudding user response:

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

  •  Tags:  
  • Related