1、String与InputStream转换
(1)String -> InputStream
- String str = "hello world";
- InputStream inputStream = new ByteArrayInputStream(str.getBytes());
(2)InputStream -> String
- byte b;
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- while((b=inpputstrea.read())!=-1){
- baos.write(b);
- }
- return baos.toString();