Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.io.BufferedReader;
import java.io.BufferedWriter;

import java.io.IOException;

import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.StringReader;

public class Main {
    /**
     * Write the provided String, line by line, in the provided OutputStream.
     */
    private static void writeStream(String toWrite, OutputStream out) throws IOException {
        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out));
        BufferedReader reader = new BufferedReader(new StringReader(toWrite));
        for (String line = reader.readLine(); line != null; line = reader.readLine()) {
            writer.write(line);
        }
        reader.close();
        writer.close();
    }
}