- /**
- * @param useTerminal
- * the useTerminal to set
- */
- public void setUseTerminal(final boolean useTerminal) {
- this.useTerminal = useTerminal;
- }
+ for (final char c : input.toCharArray()) {
+ if (c == '\'') {
+ result.append("'\\''");
+ continue;
+ }
+ result.append(c);
+ }
+
+ return result.toString();
+ }
+
+ public void execute(final EncodingOptions encodingOptions) {
+ try {
+ String command = getCommand(encodingOptions);
+
+ if (doUseTerminal())
+ command = "xterm -e '" + encodeApostrophes(command) + "'";
+
+ System.out.println("Executing command: " + command);
+
+ final Runtime run = Runtime.getRuntime();
+ Process pr;
+ pr = run.exec(new String[] { "/bin/bash", "-c", command });
+
+ pr.waitFor();
+
+ } catch (final Exception e) {
+ System.out.println(e.toString());
+ e.printStackTrace();
+ }
+
+ }
+
+ public String getCommand(final EncodingOptions encodingOptions) {
+ return converter.getCommand(source, target, encodingOptions,
+ targetFormat);
+ }
+
+ /**
+ * @param useTerminal
+ * the useTerminal to set
+ */
+ public void setUseTerminal(final boolean useTerminal) {
+ this.useTerminal = useTerminal;
+ }