title: JAVA string encoding conversion issues
body: <p>I have a piece of code working fine when started in netbeans (this code replaces some string in content.xml file extracted from .odt file):</p>
  
  <pre><code>String cont = new String(Utils.readBinaryFile(path + "/content.xml"));
  for (Patterns p : patterns) {
      cont = cont.replaceAll(p.search.replaceAll("\\{", "\\\\{"), p.replace.replaceAll("\n", "&lt;text:line-break/&gt;").replaceAll("\\{", "\\\\{"));
  }
  Utils.saveToFile(path + "/content.xml", cont.getBytes("UTF-8"), false);
  </code></pre>
  
  <p>and</p>
  
  <pre><code>/**
   * Saves the binary data to the file, if append is FALSE, the data in the file is overwritten
   * @param fileName
   * @param data
   * @param append 
   */
      public static void saveToFile(String fileName, byte[] data, boolean append) {
      try {
          try (FileOutputStream out = new FileOutputStream(fileName, append)) {
          out.write(data);
          }
      } catch (IOException iOException) {
          System.err.println(iOException.getMessage());
      }
      }
  </code></pre>
  
  <p>If I use the code in Windows in command line like java -jar .... the characters saved in the file have broken conversion.
  I realize that it comes from fact that windows works in my case in encoding CP1250 and when I start my code as java -jar the CP1250 is used.The question is how to make this working fine? I do not use that code in command line, but in applet and code run from the applet behaves exactly like the one run from command line in CP1250.</p>
  
  <p>I read many articles about encoding but nothing seemed to help me, but running from command line with specified encoding:</p>
  
  <pre><code>java -Dfile.encoding=utf-8 -jar Office.jar
  </code></pre>
  
  <p>solved the issue. </p>
  
  <p>Realizing that I then wanted to pass arguments to my applet tag:</p>
  
  <pre><code>&lt;object classid='clsid:8AD9C840-044E-11D1-B3E9-00805F499D93' width='500' height='30'&gt; 
      &lt;param name='codebase_lookup' value='false'&gt; 
      &lt;param name='archive' value='" . ServerURL . "/applets/Office/Office.jar'&gt; 
      &lt;param name='code' value='OfficeApplet'&gt; 
      &lt;param name='java_arguments' value='-Dfile.encoding=utf-8'
      &lt;param name='data' value='" . $dataJSON . "'&gt; 
      &lt;comment&gt; 
          &lt;embed 
              codebase_lookup='false' 
              archive='" . ServerURL . "/applets/Office/Office.jar' 
              code='OfficeApplet' 
              width='500' 
              height='30'
              java_arguments='-Dfile.encoding=utf-8'
              data='" . $dataJSON. "' 
              type='application/x-java-applet' 
          &gt; 
              &lt;noembed&gt; 
                You need JRE 1.7+
              &lt;/noembed&gt; 
            &lt;/embed&gt; 
          &lt;/comment&gt; 
  &lt;/object&gt;
  </code></pre>
  
  <p>As you can see I am using <strong>java_arguments</strong> tag but it doesn't seem to help or maybe java_arguments are passed to JVM in wrong way or arguments are ignored, I don't know. Can somebody help me please solve that issue? I use windows 7 64 bit.
  Thanks in advance.</p>