0

Have been searching for how to read data from .twa files but couldn't find any thing.

I have .twa files which have data in it , they are located in assets folder in android project directory.

i.e Pointer Files -> xyz.twa

I want to read data from these files which have .twa extension.

If any body have any idea about these files and how to read these files do share your knowledge with me. It will be of great help.

UserDev
  • 3
  • 7
  • it's not clear what you are asking. – Yazan Apr 27 '17 at 07:54
  • still not clear, if you are facing a problem reading **a file** from assets, or this file has something special that you need more help reading/parsing/converting it ? if it's the assets issue, then this will help you http://stackoverflow.com/questions/9544737/read-file-from-assets – Yazan Apr 27 '17 at 07:58
  • They are reading .txt file and i have .twa file – UserDev Apr 27 '17 at 08:00
  • In google this is the highest rated link about the twa file extention. I can't even find anything on what app generates this file. If its a custom one you made, then you would know how to read it better than us. If it isn't- I think you're out of luck. – Gabe Sechan Apr 27 '17 at 08:10

1 Answers1

0

Try this it will help you open .twa file. This what i did with my files

First have ByteArrayInputStream

private ByteArrayInputStream file_hnd;

Now try opening file as

try {
        {

            InputStream fip = null;
            )
            fip = getAssets().open("My Files/" + file_name);//Your driectory and file name
    /*  else
        {

            fip=new FileInputStream(f);
        }*/

            byte[] b = new byte[fip.available()];
            fip.read(b);
            file_hnd = new ByteArrayInputStream(b);
            fip.close();
            file_hnd.mark(file_hnd.available() + 1);
            return true;
        }

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

Now your ByteArray i.e file_hnd has all the data from that file. For reading i did this

 try {
        file_hnd.reset();
        int chars, i = 0, index = 0;
        while ((chars = file_hnd.read()) != -1) {

                aDes[index++] = (byte) chars;//Do your reading here


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

    }

Hope this helps you.

Abdul Kawee
  • 2,687
  • 1
  • 14
  • 26