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;

public class Main {

    public static String trimTail(StringBuffer sb, char tail) {
        if (sb.length() > 0 && sb.charAt(sb.length() - 1) == tail)
            sb.deleteCharAt(sb.length() - 1);
        return sb.toString();
    }

    public static String toString(InputStream in) throws IOException {
        StringBuffer out = new StringBuffer();
        byte[] buffer = new byte[1024];
        for (int i; (i = in.read(buffer)) != -1;) {
            out.append(new String(buffer, 0, i));
        }
        return out.toString();
    }
}