title: Runtime.exec not working
body: <p>I'm trying to run the following code to swap filenames. I'm using <code>Runtime.exec</code>. The code throws <code>IOException</code>. Anyway to fix this?</p>
  
  <pre><code>try {
  Runtime.getRuntime().exec("file1=" + folderpath + " &amp;&amp; file2=/mnt/sdcard/fsimages &amp;&amp; temp=\"$(/system/xbin/mktemp -dp /mnt/sdcard)\" &amp;&amp; /system/xbin/mv \"$file1\" $temp &amp;&amp; /system/xbin/mv \"$file2\" \"$file1\" &amp;&amp; /system/xbin/mv $temp/\"$file1\" \"$file2\"");
  } catch (IOException e) {
      e.printStackTrace();
      return;
  }
  </code></pre>
  
  <p>And the error:</p>
  
  <blockquote>
    <p>02-28 07:48:02.936: W/System.err(14399): java.io.IOException: Error
    running exec(). Command: [file1=/mnt/sdcard/fsimages_3, &amp;&amp;,
    file2=/mnt/sdcard/fsimages, &amp;&amp;, temp="$(/system/xbin/mktemp, -dp,
    /mnt/sdcard)", &amp;&amp;, /system/xbin/mv, "$file1", $temp, &amp;&amp;,
    /system/xbin/mv, "$file2", "$file1", &amp;&amp;, /system/xbin/mv,
    $temp/"$file1", "$file2"] Working Directory: null Environment: null</p>
  </blockquote>
  
  <p>It looks like <em>Runtime.exec</em> is inserting a <em>coma</em> before and after every <em>&amp;&amp;</em>. Seems like the issue is in the way which <em>Runtime.exec</em> interprets <em>&amp;&amp;</em>. Why is this happening? How can I prevent this?</p>