I am trying to run a program in Algorithms (4th ed.)
package binarysearch;
import edu.princeton.cs.introcs.*;
import java.util.Arrays;
public class BinarySearch {
public static int rank(int key, int[] a)
{
int lo = 0;
int hi = a.length - 1;
while (lo <= hi)
{
int mid = lo + (hi - lo) / 2;
if (key < a[mid]) hi = mid - 1;
else if (key > a[mid]) lo = mid + 1;
else return mid;
}
return -1;
}
public static void main(String[] args)
{
int[] whitelist = In.readInts(args[0]);
Arrays.sort(whitelist);
while(!StdIn.isEmpty())
{
int key = StdIn.readInt();
if (rank(key, whitelist) == -1)
StdOut.println(key);
}
}
}
The command to run the program is
% java BinarySearch tinyW.txt < tinyT.txt
I added the textfile to the package I want to run.
I also added the arguments needed in the run configuration.
But Eclipse is telling me this error message.
I am not sure why Eclipse cannot open the file. I set the file permission to 777 as well manually. Any idea?