read String Line from Console - Java Language Basics

Java examples for Language Basics:Console

Description

read String Line from Console

Demo Code


//package com.java2s;
import java.util.Scanner;

public class Main {
    public static void main(String[] argv) throws Exception {
        System.out.println(readStringLine());
    }/*w w w. j a v a  2s .  co  m*/

    public static String readStringLine() {
        return new Scanner(System.in).nextLine().trim();
    }
}

Related Tutorials