@@ -226,18 +226,27 @@ private void dotToFile(String dotExeFileName, String dotFileName, String outFile
226226 // d:\graphviz-1.12\bin\dot.exe -Tgif c:\temp\ManualDraw.dot > c:\temp\ManualDraw.gif
227227 // so we follow that model here and read stdout until EOF
228228 //
229-
230- final String exeCmd =
231- escape (dotExeFileName ) +
232- " -T" + getFormatForFile (outFileName ) + " " +
233- escape (dotFileName ) +
234- " -o " +
235- escape (outFileName );
236-
237- Process p = Runtime .getRuntime ().exec (exeCmd );
238- //p.getErrorStream().
229+
230+ final String [] cmdAsArray = new String [] {
231+ escape ( dotExeFileName ),
232+ "-T" ,
233+ getFormatForFile ( outFileName ),
234+ escape ( dotFileName ),
235+ "-o" ,
236+ escape ( outFileName )
237+ };
238+
239+ StringBuilder sb = new StringBuilder ();
240+ for (String s : cmdAsArray ) {
241+ sb .append ( s ).append ( " " );
242+ }
243+
244+ final String cmdAsString = sb .toString ();
245+
246+ Process p = Runtime .getRuntime ().exec (cmdAsArray );
247+
239248 try {
240- log .debug ( "Executing: " + exeCmd );
249+ log .debug ( "Executing: " + cmdAsString );
241250// Get the input stream and read from it
242251 InputStream in = p .getErrorStream ();
243252 int c ;
@@ -248,10 +257,10 @@ private void dotToFile(String dotExeFileName, String dotFileName, String outFile
248257 int i = p .waitFor ( );
249258 if (i !=0 ) {
250259 //TODO: dump system.err
251- log .error ("Error " + i + " while executing: " + exeCmd );
260+ log .error ("Error " + i + " while executing: " + cmdAsString );
252261 }
253262 } catch (Exception ie ){
254- log .error ( "Error while executing: " + exeCmd , ie );
263+ log .error ( "Error while executing: " + cmdAsString , ie );
255264 }
256265 }
257266
0 commit comments