Raw files and reading them

Put your problem here if it does not fit any of the other categories.

Raw files and reading them

Postby Scooby » Wed Feb 23, 2011 7:22 pm

I'm working on a simple puzzle game which stores the puzzle tiles into a text file. I have the file set up as a raw resource and can read it with inputStream, and I can output it in the log to check. However, it's storing the contents as there ascii code, so if I read "2", it outputs "50".
If I were using standard java, I could use readint, but a look on the official android developer site suggests nothing like this exists for android. I'm sure I must be missing something, as reading from a text file and converting to ints seems a fairly simple simple task.

Does anyone have any ideas please?


Code: Select all
//create list for tile types
         InputStream inputStream = getResources().openRawResource(R.raw.tiles);
         int i;
            i = inputStream.read();
            while(i != -1){
               i = inputStream.read();
               Log.i(TAG, "" + i);
         catch(IOException e){
Posts: 2
Joined: Sun Feb 13, 2011 1:33 pm


Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 6 guests