package com.spoon.tools; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; public class XrStreamUtil { /** * 将InputStream转化成String */ public static String toString(InputStream is) { InputStreamReader streamReader = null; BufferedReader reader = null; StringBuilder builder = null; try { streamReader = new InputStreamReader(is); reader = new BufferedReader(streamReader); builder = new StringBuilder(); String line = ""; while ((line = reader.readLine()) != null) { builder.append(line); } return builder.toString(); } catch (IOException e) { e.printStackTrace(); } finally { try { if (reader != null) { reader.close(); } if (streamReader != null) { streamReader.close(); } } catch (IOException e) { e.printStackTrace(); } } return null; } }