java 在dos下运行多行输入的问题,有谁知到呀!
java运行时想在dos下输入多行数据要怎样实现?例如24 15 12 22
15 15 23 45
12 23 45 46
这种形式。谢谢!!!
----------------解决方案--------------------------------------------------------
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class JavaEnter {
/**
* @param args
*/
public static void main(String[] args) throws IOException{
// TODO Auto-generated method stub
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String data_in_1,data_in_2,data_in_3,data_all = null;
String data[];
data_in_1 = in.readLine();
data_in_2 = in.readLine();
data_in_3 = in.readLine();
data_all = data_in_1+" "+data_in_2+" "+data_in_3;
data = data_all.split(" ");
for(String s : data){
System.out.println(s);
}
}
}
----------------解决方案--------------------------------------------------------
这个可以吗?
----------------解决方案--------------------------------------------------------
如果是固定三行,二楼版主的代码是正确的
如果是不固定的行数,用while循环
----------------解决方案--------------------------------------------------------
回复 2楼 dadongzicool
谢了!!! ----------------解决方案--------------------------------------------------------