怎么用IO流读取一行中的多个数据并分别赋值。
如:
12.3 23.2 67.5
怎么在命令行读取并赋值,a=12.3 b=23.2 c=67.5
谢谢啦。。
------解决方案--------------------
Scanner scanner=new Scanner(System.in);
//输入 12.3 23.2 67.5
double a=scanner.nextDouble();
double b=scanner.nextDouble();
double c=scanner.nextDouble();
------解决方案--------------------
import java.io.*;
public class readsysin
{
public static void main(String[]args)
{
BufferedReader t = new BufferedReader(new InputStreamReader(System.in));
String s = " ";
try
{
while((s = t.readLine())!=null)
{
System.out.println(s);
}
}
catch(Exception e)
{
}
}
}