Is there a way to redirect input from file to stdin in Netbeans?

后端 未结 5 1373
忘了有多久
忘了有多久 2020-12-31 09:11

I\'m developing application with Netbeans and Maven. My application should obtain data from stdin. But I could not understand how to test it. Putting < data.txt

5条回答
  •  旧巷少年郎
    2020-12-31 09:27

    I am not sure how it is in NetBeans but in eclipse you can write something to console and it is redirected as STDIN to running application. I believe the same should work in NetBeans too. So, just run your application, then copy/paste content of data.txt to console and probably press .

    If nothing help use remote debugging, i.e. run your program from command prompt as following:

    java -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y MyProgram < data.txt

    then connect to this process from NetBeans.

提交回复
热议问题