一、String 转 InputStream
InputStream is = new ByteArrayInputStream(str.getBytes());
InputStream is = IOUtils.toInputStream(str,Charset.forName("utf-8"));
二、InputStream 转 String
StringBuilder sb = new StringBuilder();
String line;
BufferedReader br = new BufferedReader(new InputStreamReader(inputStream));
while ((line = br.readLine()) != null) {
sb.append(line);
}
String drstr = sb.toString();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buff = new byte[1024];
int length;
while ((length = iputStream.read(buff)) != -1) {
baos.write(buff, 0, length);
}
String dostr = baos.toString(StandardCharsets.UTF_8.name());