userMessageWriter.println("Sorting " + ifile + " -> " + ofile);
File inputFile = new File(ifile);
boolean writeStdOut = ofile.equals(STDOUT_FILE_STR);
File outputFile = writeStdOut ? null : new File(ofile);
Sorter sorter = Sorter.getSorter(inputFile, outputFile);
if (tmpDirName != null && tmpDirName.trim().length() > 0) {
File tmpDir = new File(tmpDirName);
if (!tmpDir.exists()) {
log.error("Error: tmp directory: " + tmpDir.getAbsolutePath() + " does not exist.");
throw new PreprocessingException("Error: tmp directory: " + tmpDir.getAbsolutePath() + " does not exist.");
}
sorter.setTmpDir(tmpDir);
}
sorter.setMaxRecords(maxRecords);
try {
sorter.run();
} catch (Exception e) {
e.printStackTrace();
// Delete output file as its probably corrupt
if (writeStdOut && outputFile.exists()) {
outputFile.delete();