1. String --> InputStream
InputStream convertToInputStream(String str)
{
ByteArrayInputStream is = new ByteArrayInputStream(str.getBytes());
return is;
}
2. InputStream --> String
String convertToString(InputStream is)
{
BufferedReader in = new BufferedReader(new InputStreamReader(is));
StringBuffer buffer = new StringBuffer();
String line = "";
while ((line = in.readLine()) != null)
{
buffer.append(line);
}
return buffer.toString();
}