26 package org.nexusformat.nxvalidate;
29 import java.io.IOException;
30 import java.util.logging.Level;
31 import java.util.logging.Logger;
32 import org.nexusformat.nxvalidate.exceptions.NXvalidateException;
36 private static final String NXCONVERT =
"nxconvert";
37 private static final String EXTENSION =
".reduced";
41 private String convertCommand = null;
43 public NXconvert(
final File rawfile,
final boolean keepTemp,
44 final String convertCommand)
45 throws IOException, InterruptedException {
47 this.rawfile = rawfile;
48 redfile = File.createTempFile(rawfile.getName() +
".",
51 redfile.deleteOnExit();
54 this.convertCommand = convertCommand;
60 private void printStd(
final String command,
final String out,
63 Logger.getLogger(
NXconvert.class.getName()).log(Level.INFO, command);
64 Logger.getLogger(
NXconvert.class.getName()).log(Level.INFO, out);
65 Logger.getLogger(
NXconvert.class.getName()).log(Level.WARNING, err);
71 Logger.getLogger(
NXconvert.class.getName()).log(
72 Level.INFO,
"Creating " + redfile.getAbsolutePath());
75 if(convertCommand!=null){
76 command = convertCommand +
77 " -d " + this.rawfile +
" " + redfile;;
84 Runtime rt = Runtime.getRuntime();
85 Process proc = rt.exec(command);
92 int exitValue = proc.waitFor();
95 printStd(command, out.
getOutput(), err.getOutput());
97 StringBuilder buffer =
new StringBuilder(
"Execute command \"");
98 buffer.append(command);
99 buffer.append(
"\" failed. Returned ");
100 buffer.append(exitValue);
101 throw new NXvalidateException(buffer.toString());
106 public static void main(String[] args) {
108 if (args.length != 1) {
109 Logger.getLogger(
NXconvert.class.getName()).log(Level.SEVERE,
110 "You must specify one input file");
116 }
catch (Exception e) {