Here you can find the source of convertToInputStream(String string)
public static InputStream convertToInputStream(String string)
//package com.java2s; import android.graphics.Bitmap; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.InputStream; public class Main { public static InputStream convertToInputStream(String string) { byte[] bytes = string.getBytes(); return new ByteArrayInputStream(bytes); }//from w w w. j av a 2 s. c o m public static InputStream convertToInputStream(Bitmap bitmap) { ByteArrayOutputStream expectedOutputStream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.PNG, 0 /*ignored for PNG*/, expectedOutputStream); byte[] expectedBitmapData = expectedOutputStream.toByteArray(); return new ByteArrayInputStream(expectedBitmapData); } }