[英]Taking Inputs from BufferReader
I want to scan below input in from console but BufferedReader
not scanning after 3 lines of input. 我想从控制台扫描下面的输入,但是
BufferedReader
在输入3行后不扫描。 please help .... Below is my Code 请帮助...。以下是我的代码
public static void main(String args[]) throws IOException
{
root = new trienode();
System.out.println("enter inputs");
BufferedReader s = new BufferedReader (new InputStreamReader(System.in));
String[] s1 = s.readLine().split(" ");
int n = Integer.parseInt(s1[0]);
int l = Integer.parseInt(s1[1]);
for(int i=0;i<n;i++)
{
String[] s2 = s.readLine().split(" ");
String key=s2[0];
int w=Integer.parseInt(s2[1]);
//Insert(key , w);
}
for(int j=0;j<l;j++)
{
String s3 = s.readLine();
if(search(s3)!=-1)
System.out.println(search(s3));
}
}
My Input is 我的输入是
2 1
abc 10
gef 9
ghi
Not able to scan ghi
...... Please help 无法扫描
ghi
......请帮助
Change " "
to "\\\\s+"
in split function. 在拆分功能中将
" "
更改为"\\\\s+"
。
public static void main(String args[]) throws IOException {
root = new trienode();
System.out.println("enter inputs");
BufferedReader s = new BufferedReader (new InputStreamReader(System.in));
String[] s1 = s.readLine().split("\\s+");
int n = Integer.parseInt(s1[0]);
int l = Integer.parseInt(s1[1]);
for(int i=0;i<n;i++)
{
String[] s2 = s.readLine().split("\\s+");
String key=s2[0];
int w=Integer.parseInt(s2[1]);
//Insert(key , w);
}
for(int j=0;j<l;j++)
{
String s3 = s.readLine();
if(search(s3)!=-1)
System.out.println(search(s3));
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.