java在命令行中实现输入

来源:百度知道 编辑:UC知道 时间:2024/05/16 08:54:09
比如在命令行运行后,提示输入一个值,中文英文都可以,然后根据所输入的东西,生成一个语句.
比如,输入;u
输出:u are a fool.
请在命令行下测试过再给我,因为我是菜鸟,错误的我不知道怎么改.

这样:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public static void main(String[] args) {
InputStreamReader isr = new InputStreamReader(System.in);

BufferedReader br = new BufferedReader(isr);
String s = null;
try {
s = br.readLine();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

System.out.println("Hello: " + s);

}

肯定是保无误才给你的呀!!试试看就知道了,

package com.color.util;

import java.util.Scanner;

public class InputStr{

public static void main(String[] args){
Scanner s = new Scanner(System.in);
String str = s.next();
System.out.println(str+" are a fool!");
}
}

import java.io.*;
public class test{
public static void main(String args[]){
byte buffer=new byte[512