advertisement

Article:
  Ant and AppleScript
Subject:   Improved Java Code
Date:   2003-10-03 20:50:55
From:   anonymous2
I thought your java code could use some improvement. Since you are only appending items to the array list cmd, it would have been simpler to just do:


cmd.add("/usr/bin/osascript");
if (language != null) {
cmd.add("-l");
cmd.add(language);
}


...


Also, ArrayList defines the method toArray(Object[]), so constructing the array could have been done like this:


String[] cmdArray = (String[]) cmd.toArray(new String[0]);


I think these changes would make the code a lot cleaner.