redirecting and piping
-
How is the text file below (% java BinarySearch largeW.txt < largeT.txt) read as "args[0]". Code snippet would be apprecated
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);
}
}% java BinarySearch largeW.txt < largeT.txt 499569 984875 ...
-
How is the text file below (% java BinarySearch largeW.txt < largeT.txt) read as "args[0]". Code snippet would be apprecated
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);
}
}% java BinarySearch largeW.txt < largeT.txt 499569 984875 ...
args[0]
is the file largeW.txt, while largeT.txt will be piped direct into the program asStdIn
. I'm not sure what code snippet we can offer since the snippet above explains it so succinctly.Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman
-
args[0]
is the file largeW.txt, while largeT.txt will be piped direct into the program asStdIn
. I'm not sure what code snippet we can offer since the snippet above explains it so succinctly.Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman
My question is: How is arg[0] pointing to the text file? Code Snippet would be appreciated
-
My question is: How is arg[0] pointing to the text file? Code Snippet would be appreciated
You have the code snippet, look at the definition of
main
. Theargs
parameter is set by the framework as an array of strings which correspond to the parameters on the command line.Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman