Here you can find the source of inputStream2String(InputStream is)
Parameter | Description |
---|---|
is | a parameter |
Parameter | Description |
---|---|
IOException | an exception |
public static String inputStream2String(InputStream is) throws IOException
//package com.java2s; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; public class Main { /**/* w w w . j a v a 2 s . c o m*/ * @param is * @return * @throws IOException */ public static String inputStream2String(InputStream is) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); int i = -1; while ((i = is.read()) != -1) { baos.write(i); } return baos.toString(); } }