Eclipse能否从文件中读取stdin?
res\in.txt
,还有一个输出文件:res\out.txt
创建一个包含所需目标的build.xml
(这只是一个示例):
<project basedir="." default="run" name="Tests">
<target name="clean">
<delete dir="bin"/>
</target>
<target name="compile">
<mkdir dir="bin"/>
<javac srcdir="src" destdir="bin" includeantruntime="false"/>
</target>
<target name="build" depends="clean,compile"/>
<target name="run" depends="build">
<java classname="Main" input="res\in.txt" output="res\out.txt" classpath="bin" />
</target>
</project>
在Eclipse中转到:Run->External Tools->External Tools Configurations->Ant Build-> New Launch Configuration
使用以下配置:
主要部分
构建文件:${workspace_loc:/Tests/build.xml}
基础目录:${workspace_loc:/Tests}
*注意:Tests是我的Eclipse项目名称
现在,您可以通过单击运行外部工具栏按钮并根据需要更改输入或输出文件来运行项目。