read String Value from Console - Java Language Basics

Java examples for Language Basics:Console

Description

read String Value 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(readStringValue());
    }/*  ww  w.  j  a v a 2  s.  co m*/

    public static String readStringValue() {
        return new Scanner(System.in).next().trim();
    }
}

Related Tutorials