public class Utils {
public static String getTextFromStream(InputStream is){
int len=0;
byte[] b=new byte[1024];
ByteArrayOutputStream baos=new ByteArrayOutputStream();
try {
while((len=is.read(b))!=-1){
baos.write(b,0,len);
}
} catch (IOException e) {
e.printStackTrace();
}
String text=new String(baos.toByteArray());
return text;
}
}
输入流转换成字符串
最新推荐文章于 2022-08-11 14:31:10 发布