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) {
        String s = "tutorial from java2s.com ";
        try {

            PrintWriter pw = new PrintWriter(System.out);

            // append the sequence
            pw.append(s);

            // flush the writer
            pw.flush();

            // print another string
            pw.println("This is an example");

            // flush the writer again
            pw.flush();

            // close the writer
            pw.close();

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