Alex Rivera | Logout

what's the readStream() method? i just can not find it anywhere,

Asked 2011-12-04T14:44:03.077
20

i searched how to use resources under the directory "assets", then i find a snippet:

AssetManager assets = getAssets();
((TextView)findViewById(R.id.txAssets)).setText(**readStream**(assets.open("data.txt")));

i just cannot find what's the readStream method, it is not in the google apis i tried to download the newest Java api document, but still can not find it, anybody knows that?

Edit
Report

1 Answer

28

As @Felix said it is a user-defined method. On the page you linked, they defined readStream like this:

  private String readStream(InputStream is) {
    try {
      ByteArrayOutputStream bo = new ByteArrayOutputStream();
      int i = is.read();
      while(i != -1) {
        bo.write(i);
        i = is.read();
      }
      return bo.toString();
    } catch (IOException e) {
      return "";
    }
}
answered 2011-12-04T15:01:40.823

Your Answer