Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. private static String readFromAsset(Context context, String path) throws JSONException, IOException {
  2.  
  3.         byte[] buffer;
  4.         InputStream inputStream;
  5.         try {
  6.             inputStream = context.getAssets().open(path);
  7.         } catch (IOException e) {
  8.             IOException ioException= new IOException(e.toString()+"\n\r"+
  9.                     "Local REST must store in Asset Resource Folder.");
  10.             ioException.setStackTrace(e.getStackTrace());
  11.             throw ioException;
  12.  
  13.  
  14.         }
  15.         int size = inputStream.available();
  16.  
  17.         buffer = new byte[size];
  18.  
  19.         inputStream.read(buffer);
  20.         inputStream.close();
  21.  
  22.  
  23.         return new String(buffer);
  24.  
  25.     }