Android examples for java.io:InputStream
Convert InputStream to string
import android.util.Base64; import android.util.Log; import java.io.BufferedReader; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; import java.text.DecimalFormat; import java.text.NumberFormat; import java.util.ArrayList; import java.util.Locale; import java.util.Vector; import java.util.regex.Pattern; public class Main{ public static String inputStreamToString(InputStream stream) { try {// w w w .j av a2 s. c o m BufferedReader reader = new BufferedReader( new InputStreamReader(stream), 8192); StringBuilder sb = new StringBuilder(); String line = null; while ((line = reader.readLine()) != null) { if (line.trim().length() > 0) { sb.append(line); } } return sb.toString(); } catch (IOException e) { e.printStackTrace(); } return ""; } }