Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;

public class Main {
    public static String readFromStream(InputStream in) throws IOException {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        int len = 0;
        byte[] buf = new byte[1024];
        if ((len = in.read(buf)) != -1) {
            out.write(buf, 0, len);
        }
        String result = out.toString();
        in.close();
        out.close();
        return result;
    }
}