title: Copying Xml File From Res/Xml Folder to Device Storage
body: <p>I'm trying to copy an xml file from the res/xml folder to the device storage but I'm really struggling on how to do this.</p>
  
  <p>I know that the starting point is to get an <code>InputStream</code> to read the xml file. This is achieved by using this:</p>
  
  <pre><code>InputStream is = getResources().openRawResource(R.xml.xmlfile);
  </code></pre>
  
  <p>Eventually the output stream will be:</p>
  
  <pre><code>file = new File("xmlfile.xml");
  FileOutputStream fileOutputStream = new FileOutputStream(file);
  </code></pre>
  
  <p>But I'm really struggling on how to read and copy all the information from the initial xml file correctly and accurately. </p>
  
  <p>So far, I've tried using various <code>InputStream</code> and <code>OutputStream</code> to read and write (<code>DataInputStream</code>, <code>DataOutputStream</code>, <code>OutputStreamWriter</code>, etc.) but I still didn't managed to get it correctly. There are some unknown characters (encoding issue?) in the produced xml file. Can anyone help me on this? Thanks!</p>