title: How to reduce the file size of a xml file that is created using java?
body: <p>I have to convert a text file with coordinates into a xml file. But the point of converting the text file into a xml file is so that the file size to be smaller. How can I reduce the size of my file?</p>
  
  <pre><code>public void writeXML() throws Exception
      {   
          ArrayList&lt;Frame&gt; frameList = new ArrayList&lt;Frame&gt;();    
          frameList = readFile();
  
          DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
          DocumentBuilder dBuilder;
  
          try
          {
              dBuilder = dbFactory.newDocumentBuilder();
              Document doc = dBuilder.newDocument();
  
              // append stuff                
  
              TransformerFactory transformerFactory = TransformerFactory.newInstance();
  
              Transformer transformer = transformerFactory.newTransformer();
  
              //transformer.setOutputProperty(OutputKeys.INDENT, "yes");
              DOMSource source = new DOMSource(doc);
  
              StreamResult console = new StreamResult(System.out);
              StreamResult file = new StreamResult(new File("file.xml"));
  
              //transformer.transform(source, console);
              transformer.transform(source, file);
              System.out.println("DONE");
          }
          catch (Exception e)
          {
              e.printStackTrace();
          }    
      }
  </code></pre>