public class StringUtils {
public static String StreamToString(InputStream in) throws IOException{
//定义一个内存输出流
ByteArrayOutputStream baos=new ByteArrayOutputStream();
//读取流
byte[] buf = new byte[1024];
int len=-1;
while((len=in.read(buf))!=-1){
baos.write(buf,0,len);
}//将流转换成字符串
String content = new String(baos.toString());
return content;
}
}