Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.io.Console;
import java.io.IOException;

public class Main {
    public static void main(String[] args) throws IOException {
        Console cons = System.console();
        if (cons == null) {
            System.out.println("Console is null");
            System.exit(-1);
        } else {
            System.out.println("Enter text, or \"z\" to exit:");
            while (true) {
                char c = (char) cons.reader().read();
                System.out.println("" + c);
                if (c == 'z') {
                    System.exit(0);
                }
            }
        }
    }
}