Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

public class Main {
    public static String streamToString(InputStream stream) {
        InputStreamReader reader = new InputStreamReader(stream);
        StringBuilder sb = new StringBuilder();
        char[] buf = new char[256];
        try {
            while (reader.read(buf) != -1) {
                sb.append(buf);
            }
        } catch (IOException e) {
            // Darn
        } finally {
            try {
                stream.close();
            } catch (IOException e) {
            }
        }
        return sb.toString();
    }
}