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) {
        char[] c = { 'j', 'a', 'v', 'a', '2', 's', '.', 'c', 'o', 'm' };

        Writer writer = new PrintWriter(System.out);

        try {
            // write a portion of a char array
            writer.write(c, 0, 5);

            // flush the writer
            writer.flush();

            // write another portion of a char array
            writer.write(c, 5, 5);

            // flush the stream again
            writer.close();

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