如果要输入流转换为字符串使用ByteArrayOutputStream来实现:
private static String changeInputStream(InputStream inputStream, String encode) { // TODO Auto-generated method stub ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); byte[] data = new byte[1024]; int len = 0; String result = ""; if (inputStream != null) { try { while ((len = inputStream.read(data)) != -1) { outputStream.write(data, 0, len); } result = new String(outputStream.toByteArray(), encode); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return result; }