/**
* 将一个字符串转化为输入流
*/
publicstatic InputStream getStringStream(String sInputString)
{
if (sInputString != null && !sInputString.trim().equals(""))
{
try
{
ByteArrayInputStream tInputStringStream = new ByteArrayInputStream(sInputString.getBytes());
return tInputStringStream;
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
returnnull;
}

/**
* 将一个输入流转化为字符串
*/
publicstatic String getStreamString(InputStream tInputStream)
{
if (tInputStream != null)
{
try
{
BufferedReader tBufferedReader = new BufferedReader(new InputStreamReader(tInputStream));
StringBuffer tStringBuffer = new StringBuffer();
String sTempOneLine = new String("");
while ((sTempOneLine = tBufferedReader.readLine()) != null)
{
tStringBuffer.append(sTempOneLine);
}
return tStringBuffer.toString();
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
returnnull;
}
--转自

该贴由koei123转至本版2015-7-26 22:50:10