Java tutorial
//package com.java2s; //License from project: Open Source License import java.io.ByteArrayOutputStream; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.UnsupportedEncodingException; import android.content.Context; public class Main { public static String imgCacheRead(Context context, String cacheImgFileName) { int len = 1024; byte[] buffer = new byte[len]; try { FileInputStream fis = context.openFileInput(cacheImgFileName); ByteArrayOutputStream baos = new ByteArrayOutputStream(); int nrb = fis.read(buffer, 0, len); // read up to len bytes while (nrb != -1) { baos.write(buffer, 0, nrb); nrb = fis.read(buffer, 0, len); } buffer = baos.toByteArray(); fis.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } try { return new String(buffer, "utf-8"); } catch (UnsupportedEncodingException e) { return null; } } }