Example usage for java.lang System in

List of usage examples for java.lang System in

Introduction

In this page you can find the example usage for java.lang System in.

Prototype

InputStream in

To view the source code for java.lang System in.

Click Source Link

Document

The "standard" input stream.

Usage

From source file:BRReadLines.java

public static void main(String args[]) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String str;//from   ww  w  .j  ava 2s . c  om

    System.out.println("Enter lines of text.");
    System.out.println("Enter 'stop' to quit.");
    do {
        str = br.readLine();
        System.out.println(str);
    } while (!str.equals("stop"));
}

From source file:Main.java

public static void main(String args[]) throws IOException {
    BufferedReader buff = new BufferedReader(new InputStreamReader(System.in));
    System.out.println("Enter the char:");
    String str = buff.readLine();
    for (int i = 0; i < str.length(); ++i) {
        char c = str.charAt(i);
        int j = (int) c;
        System.out.println("ASCII OF " + c + " = " + j + ".");
    }//from w w w.  j  a v  a  2  s  .  co  m
}

From source file:MainClass.java

public static void main(String[] args) throws Exception {
    LineNumberReader lineCounter = new LineNumberReader(new InputStreamReader(System.in));

    String nextLine = null;/* ww  w  .j av  a 2 s  .  c  o  m*/
    System.out.println("Type any text and press return. Type 'exit' to quit the program.");
    try {
        while ((nextLine = lineCounter.readLine()).indexOf("exit") == -1) {
            if (nextLine == null)
                break;
            System.out.print(lineCounter.getLineNumber());
            System.out.print(": ");
            System.out.println(nextLine);
        }
    } catch (Exception done) {
        done.printStackTrace();
    }
}

From source file:BRRead.java

public static void main(String args[]) throws IOException {
    char c;//w w  w.j a v  a 2s . co  m
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    System.out.println("Enter characters, 'q' to quit.");
    do {
        c = (char) br.read();
        System.out.println(c);
    } while (c != 'q');
}

From source file:Main.java

public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    String text = "q";
    while (true) {
        System.out.print("Please type a message (Q/q to quit) and press enter:");
        text = br.readLine();//from  ww w  . ja v a  2 s . c o m
        if (text.equalsIgnoreCase("q")) {
            System.out.println("We have  decided to exit  the   program");
            break;
        } else {
            System.out.println("We typed: " + text);
        }
    }
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    System.out.print("Enter your name: ");
    InputStreamReader reader = new InputStreamReader(System.in);
    BufferedReader in = new BufferedReader(reader);
    String name = in.readLine();/*from w ww.  j a va  2 s.  c o  m*/
    System.out.println("Hello, " + name + ". Enter three ints...");
    int[] values = new int[3];
    double sum = 0.0;
    for (int i = 0; i < values.length; i++) {
        System.out.print("Number " + (i + 1) + ": ");
        String temp = in.readLine();
        values[i] = Integer.parseInt(temp);
        sum += values[i];
    }
    System.out.println("The average equals " + sum / values.length);
}

From source file:UseTrim.java

public static void main(String args[]) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String str;/*from  w ww.ja  va  2s. co  m*/

    System.out.println("Enter 'stop' to quit.");
    System.out.println("Enter letter: ");
    do {
        str = br.readLine();
        str = str.trim();

        if (str.equals("I"))
            System.out.println("I");
        else if (str.equals("M"))
            System.out.println("M");
        else if (str.equals("C"))
            System.out.println("C.");
        else if (str.equals("W"))
            System.out.println("W");
    } while (!str.equals("stop"));
}

From source file:ParseDemo.java

public static void main(String args[]) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String str;//  w  w w . j  av  a2s  .c  om
    int i;
    int sum = 0;

    System.out.println("Enter numbers, 0 to quit.");
    do {
        str = br.readLine();
        try {
            i = Integer.parseInt(str);
        } catch (NumberFormatException e) {
            System.out.println("Invalid format");
            i = 0;
        }
        sum += i;
        System.out.println("Current sum is: " + sum);
    } while (i != 0);
}

From source file:TinyEdit.java

public static void main(String args[]) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String str[] = new String[100];

    System.out.println("Enter lines of text.");
    System.out.println("Enter 'stop' to quit.");
    for (int i = 0; i < 100; i++) {
        str[i] = br.readLine();/* ww  w .ja  v  a2s.c o  m*/
        if (str[i].equals("stop"))
            break;
    }

    System.out.println("\nHere is your file:");

    for (int i = 0; i < 100; i++) {
        if (str[i].equals("stop"))
            break;
        System.out.println(str[i]);
    }
}

From source file:MainClass.java

public static void main(String[] args) {

    try {/*from w ww.j a va  2 s . co m*/
        copy(System.in, System.out);
    } catch (IOException ex) {
        System.err.println(ex);
    }
}