所以我从这里有 BinarySearch 类,我试图在 Eclipse 中运行它。我tinyW.txt < tinyT.txt
在运行 > 运行配置 > 参数 > 程序参数中添加了参数。但它没有给我预期的输出,而是在 Eclipse 的控制台中等待我的输入。
知道如何在日食后立即完成吗?
该程序依赖于这个档案。
这是您的主要方法:
public static void main(String[] args) {
// read in the integers from a file
In in = new In(args[0]);
int[] whitelist = in.readAllInts();
// more.....
你的In
类是用这个方法实例化的(看这个)
public In(String s) {
try {
// first try to read file from local file system
File file = new File(s);
if (file.exists()) {
// more....
这意味着您的第一个参数是传递以从中获取数据的实际文件名。由于您的参数数组是["tinyW.txt", "<", "tinyT.txt"]
您作为参数传递tinyW.txt
并忽略其余部分。
选项 1
一切都说完了,假设这tinyW.txt
是输入文件,只需从 Eclipse 配置中删除<
并tinyT.txt
保留文件名。
然后,在进入Run
菜单并选择Debug Configurations
->部分Common
中Standard Input and Output
,您可以选择File
并放置一个路径来为输出创建文件。
选项 2
仅从参数列表中删除<
并修改BinarySearch
类。您可以使用第二个参数作为创建新文件并将输出写入该文件的路径,而不是将输出输出到标准输出。