@@ -231,18 +231,27 @@ private void dotToFile(String dotExeFileName, String dotFileName, String outFile
231231 // d:\graphviz-1.12\bin\dot.exe -Tgif c:\temp\ManualDraw.dot > c:\temp\ManualDraw.gif
232232 // so we follow that model here and read stdout until EOF
233233 //
234-
235- final String exeCmd =
236- escape (dotExeFileName ) +
237- " -T" + getFormatForFile (outFileName ) + " " +
238- escape (dotFileName ) +
239- " -o " +
240- escape (outFileName );
241-
242- Process p = Runtime .getRuntime ().exec (exeCmd );
243- //p.getErrorStream().
234+
235+ final String [] cmdAsArray = new String [] {
236+ escape ( dotExeFileName ),
237+ "-T" ,
238+ getFormatForFile ( outFileName ),
239+ escape ( dotFileName ),
240+ "-o" ,
241+ escape ( outFileName )
242+ };
243+
244+ StringBuilder sb = new StringBuilder ();
245+ for (String s : cmdAsArray ) {
246+ sb .append ( s ).append ( " " );
247+ }
248+
249+ final String cmdAsString = sb .toString ();
250+
251+ Process p = Runtime .getRuntime ().exec (cmdAsArray );
252+
244253 try {
245- log .debug ( "Executing: " + exeCmd );
254+ log .debug ( "Executing: " + cmdAsString );
246255// Get the input stream and read from it
247256 InputStream in = p .getErrorStream ();
248257 int c ;
@@ -253,10 +262,10 @@ private void dotToFile(String dotExeFileName, String dotFileName, String outFile
253262 int i = p .waitFor ( );
254263 if (i !=0 ) {
255264 //TODO: dump system.err
256- log .error ("Error " + i + " while executing: " + exeCmd );
265+ log .error ("Error " + i + " while executing: " + cmdAsString );
257266 }
258267 } catch (Exception ie ){
259- log .error ( "Error while executing: " + exeCmd , ie );
268+ log .error ( "Error while executing: " + cmdAsString , ie );
260269 }
261270 }
262271
0 commit comments