Based more or less line for line from EULA.java in apps-for-android Google Code project.
http://code.google.com/p/apps-for-android/source/browse/trunk/Photostream/src/com/google/android/photostream/Eula.java public static CharSequence readAsset(String asset, Activity activity) { BufferedReader in = null; try { in = new BufferedReader(new InputStreamReader (activity.getAssets().open(asset))); String line; StringBuilder buffer = new StringBuilder(); while ((line = in.readLine()) != null) { buffer.append(line).append('\n'); } return buffer; } catch (IOException e) { return ""; } finally { closeStream(in); } } Al. On Feb 19, 10:31 am, zeeshan <genx...@gmail.com> wrote: > i am trying to access a resource file by > > try { > InputStream is = getAssets().open("read_asset.txt"); > > int size = is.available(); > > byte[] buffer = new byte[size]; > is.read(buffer); > is.close(); > > // Convert the buffer into a string. > String text = new String(buffer); > > // Finally stick the string into the text view. > TextView tv = (TextView)findViewById(R.id.text); > tv.setText(text); > } catch (IOException e) { > > // Should never happen! > throw new RuntimeException(e); > } > > and it is returning me exception, please help me > > thanks --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---