Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.io.*;

public class Main {

    public static void main(String[] args) {
        CharSequence csq = "from java2s.com!";

        Writer writer = new PrintWriter(System.out);

        try {
            // append a sequence and change line
            writer.append("This is an example\n");

            // flush the writer
            writer.flush();

            // append a new sequence
            writer.append(csq);

            // flush the writer to see the result
            writer.flush();

        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }
}