一. 字符串转流
1.
public static InputStream StrToStream(String str){
InputStream in = new ByteArrayInputStream(str.getBytes());
return in;
}
2.
创建字符串输入流
StringReader in=new StringReader(str);
创建字符串输出流
StringWriter out=new StringWriter();
二. 流转字符串
public static byte[] StreamToByte(InputStream in){
byte[] b = null;
try{
b = new byte[in.available()];
in.read(b);
in.close();
}catch(Exception e){
log.warn("流转字节数组异常:"+e.getMessage());
}
return b;
}