I am trying to run "cut" inside a java program, but I am lost in terms of how to split the array of commands. My program in the command line is the following:
cut file.txt -d' ' -f1-2 > hits.txt
And I am trying to run it inside java like this
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec(new String[]{"file.txt"," -d' ' -f1-2 "," > hits.txt"});
pr.waitFor();
But I get the following runtime error
Exception in thread "main" java.io.IOException: Cannot run program "cut file.txt": java.io.IOException: error=2, No such file or directory
I attribute this error to the array of Strings I am using as exec commands. Any ideas on how to do this? Also any known documentation on the issue. Thanks
pr2andrt2? Please fix your variable names.file.txt, or, more likely, file.txt is not in the same directory from where you are running the java process. You may correct the relative path or switch to an absolute path.