0

I use below code for read txt file and convert to string

After convert, added dot to first line and i cant convert number string to integer

Code :

StringBuilder buf = new StringBuilder(); BufferedReader in = null; try { InputStream is = context.getAssets().open("db.txt"); in = new BufferedReader(new InputStreamReader(is)); String str; while ((str = in.readLine()) != null) { buf.append(str); } in.close(); Log.i("error", "" + buf.toString().trim()); } catch (IOException e) { e.printStackTrace(); } 

Errorlog :

enter image description here

5
  • where is the dot? Commented Oct 20, 2016 at 10:56
  • you should check it this answer stackoverflow.com/a/13357785/5773037 Commented Oct 20, 2016 at 10:57
  • The code to read a txt file seems fine. Maybe there is a dot at the beginning of your db.txt? Commented Oct 20, 2016 at 11:06
  • @cherry-wave no in db.txt not dot first of file Commented Oct 20, 2016 at 11:55
  • So I used your exact code to post a txt-file with random content and no extra dot was added at the beginning. Maybe you could post your db.txt file (just the first line?) Commented Oct 20, 2016 at 12:16

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.