无法输入问题的解决
今天在写网络编程的时候,从控制台输入一直处于等待状态,搞了半天,查了Scanner是不是会一直阻塞等等,都没有解决,后来将问题定格于控制台无法输入,网上搜寻一番终于有了结果,原来TMD junit里测试方法不能在控制台输入数据,但是我找到了解决的办法
Scanner scan = new Scanner(System.in);
System.out.println("aaa");
while(scan.hasNext()){
String str = scan.next();
System.out.println(str);
buf.put((new Date().toString()+"\n"+str).getBytes());
buf.flip();
sChannel.write(buf);
buf.clear();
}
进入help->Edit Custom VM Options
添加-Deditable.java.test.console=true,然后重启生效!重启说三遍!!
来源:CSDN
作者:逆凡~
链接:https://blog.csdn.net/qq_38735055/article/details/102615304