InputStream,String相互转化

String --> InputStream

InputStream String2InputStream(String str){
ByteArrayInputStream stream = new ByteArrayInputStream(str.getBytes());
return stream;
}

InputStream --> String

String inputStream2String(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();
}
上一篇:angular-cli.json配置参数解释,以及依稀常用命令的通用关键参数解释


下一篇:Codeforces Round #384(div 2)