将数据写入 System.in [英] Writing data to System.in
本文介绍了将数据写入 System.in的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我们的应用程序中,我们期望在 Thread
中的用户输入如下:
In our application, we expect user input within a Thread
as follows :
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
我想在我的单元测试中通过那部分,以便我可以恢复线程来执行其余的代码.如何从 junit 中将内容写入 System.in
?
I want to pass that part in my unit test so that I can resume the thread to execute the rest of the code. How can I write something into System.in
from junit?
推荐答案
你要做的是使用setIn()
来自 System
.这将使您可以将数据从 junit 传递到 System.in
.
这篇关于将数据写入 System.in的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文