I've read many answers about this question but nothing was found about the comparison between two files, actually this is a sample of the book Algorithms based on BinarySearch, here is the source code
import java.util.Arrays;
import edu.princeton.cs.algs4.*;
public class prac1_1_23{
public static boolean BinaryLookup(int key, int[] arr) {
int low = 0;
int high = arr.length - 1;
while(low <= high) {
int mid = low + ((high - low) >> 1);
if(key < arr[mid])
high = mid - 1;
else if(key > arr[mid])
low = mid + 1;
else
return true;
}
return false;
}
public static void main(String[] args) {
char symbol = '-';
int[] whitelist = new In(args[0]).readAllInts();
Arrays.sort(whitelist);
while(!StdIn.isEmpty()) {
int key = StdIn.readInt();
boolean found = BinaryLookup(key, whitelist);
if('+' == symbol && !found)
StdOut.println(key);
if('-' == symbol && found)
StdOut.println(key);
}
}
}
This sample utilizes a library made by the author of the book, which can be accessed via Algorithms, and the question is when I want to run this program via the PowerShell of windows,like the command
java prac1_1_23 largeW.txt < largeT.txt
I got a problem like error
actually I find a solution to run this code but is useless to solve it on PowerShell which requires me to use the commandline program written by the author of this book which can be download on the website of "algs4.cs.princeton.edu/windows/", and it need to compile and run the program with the commandline like
javac-algs4 prac1_1_23.java //compile command
java-algs4 prac1_1_23 largeW.txt < largeT.txt //run command
it does work but I wonder if we can utilize the original CLI because I found someone can run the original code on the Linux operating system without problems.
Any help is appreciated, thank you.