java在命令行中实现输入
发布网友
发布时间:2022-04-22 14:59
我来回答
共4个回答
热心网友
时间:2023-10-19 05:45
这样:
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);
}
肯定是保无误才给你的呀!!试试看就知道了,
热心网友
时间:2023-10-19 05:45
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!");
}
}
热心网友
时间:2023-10-19 05:46
int rs=System.in.read();
或者
int rs=System.in.read(byte[] b);
for(int i=0;i<b.length;i++){
System.out.println("b["+i+"]"+b[i]);//输出b
}
热心网友
时间:2023-10-19 05:46
import java.io.*;
public class test{
public static void main(String args[]){
byte buffer=new byte[512];
System.in.read(buffer);
String str=new String(buffer);
System.out.println("请你输入:");
System.out.println("what you are input is"+str);
}
}