Java Dump Stream dumpInputStreamAsString(InputStream is)

Here you can find the source of dumpInputStreamAsString(InputStream is)

Description

dump Input Stream As String

License

Apache License

Declaration

public static void dumpInputStreamAsString(InputStream is)
            throws IOException 

Method Source Code

//package com.java2s;
/*//from   w  ww .  j a va2 s  . co  m
 * Copyright WSO2, Inc. (http://wso2.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.io.*;

public class Main {
    public static void dumpInputStreamAsString(InputStream is)
            throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(is));
        StringBuilder sb = new StringBuilder();
        String line;
        while ((line = br.readLine()) != null) {
            sb.append(line);
        }
        System.out.println(sb.toString());
    }
}

Related

  1. dumpFile(String r_file, OutputStream outputstream)
  2. dumpInputOutputStream(InputStream is, OutputStream os)
  3. dumpInputStream(InputStream instream)
  4. dumpInputStream(InputStream is, PrintStream p)
  5. dumpInputStream(InputStream stream)
  6. dumpInputStreamIntoString(InputStream f, String encoding)
  7. dumpMap(PrintStream out, Map Values)
  8. dumpStream(InputStream in, PrintStream dump, boolean closeIn)
  9. dumpStream(InputStream in, String file)