Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.io.BufferedInputStream;
import java.io.InputStream;
import java.io.IOException;

public class Main {
    public static String readInputStream(InputStream i) throws IOException {
        BufferedInputStream s = new BufferedInputStream(i);
        byte[] buf = new byte[512];
        int len = -1;
        StringBuilder sb = new StringBuilder();

        while ((len = s.read(buf, 0, buf.length)) != -1) {
            sb.append(new String(buf, 0, len));
        }

        return sb.toString();
    }
}