Eclipse reading stdin (System.in) from a file

后端 未结 11 1997
轮回少年
轮回少年 2020-11-27 03:40

Is it possible for Eclipse to read stdin from a file?

11条回答
  •  被撕碎了的回忆
    2020-11-27 03:57

    What I did was to create an Ant target and launch it as "Run External" from Eclipse, here are the steps:

    • I have one input file to read from: res\in.txt and one for the output: res\out.txt
    • Create a build.xml with the targets you require (this is just an example):

      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
    • In Eclipse go to: Run->External Tools->External Tools Configurations->Ant Build-> New Launch Configuration use the following configuration:

    Section Main

    Buildfile: ${workspace_loc:/Tests/build.xml}

    Base Directory: ${workspace_loc:/Tests}

    *Note: Tests is the name of my Eclipse project

    Now you can run your project by clicking in the Run Extenal tool bar button and change the input or output files as you needed

提交回复
热议问题