Android examples for java.io:ByteArrayOutputStream
read InputStream into ByteArrayOutputStream
import android.content.ComponentName; import android.content.Context; import android.content.pm.ActivityInfo; import android.content.pm.ApplicationInfo; import android.content.pm.PackageInfo; import android.content.res.Resources; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main{ public static String read(InputStream in) throws IOException { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); byte[] bytes = new byte[1024]; int len = 0; while ((len = in.read(bytes)) != -1) { buffer.write(bytes, 0, len); }//from ww w. ja v a 2s .c om return buffer.toString(); } }