将流信息转化成字符串

来源:互联网 发布:手游代练软件 编辑:程序博客网 时间:2024/05/01 01:39

public class StreamUtils {
 
 /**
  * 将流信息转化成字符串
  * @param in
  * @return
  * @throws IOException
  */
 
 
 public static String parserStream(InputStream in) throws IOException{
  //字符流,读取流
  BufferedReader br = new BufferedReader(new InputStreamReader(in));
  //写入流
  StringWriter  sw = new StringWriter();
  //缓存区
  String str = null;
  //读写操作
  while((str = br.readLine()) != null){
   //写操作
   sw.write(str);
  }
  //关流
  sw.close();
  br.close();
  return sw.toString();
 }
 
}

0 0
原创粉丝点击