Java tutorial
//package com.java2s; import android.text.TextUtils; import java.io.ByteArrayInputStream; import java.io.InputStream; import java.io.UnsupportedEncodingException; public class Main { public static InputStream stringToInputStream(String str, String code) { if (TextUtils.isEmpty(code)) { return new ByteArrayInputStream(str.getBytes()); } else { try { return new ByteArrayInputStream(str.getBytes(code)); } catch (UnsupportedEncodingException e) { e.printStackTrace(); return new ByteArrayInputStream(str.getBytes()); } } } public static boolean isEmpty(String input) { if (input == null || "null".equals(input) || TextUtils.isEmpty(input)) return true; return false; } }