Code example for StringWriter

Methods: flushtoString

	public static CharSequence loadXmlStandalone(File file) throws Exception {
		// Dom4j handles the full spattering of crazy entity stuff that mapnik xml 
		// uses.  We bring it throug a DOM4j Document which is wasteful but avoids 
		// subtle entity related problems I was having 
		// TODO: Spend more time digging into this 
		StringWriter out=new StringWriter((int)file.length() * 4);
		SAXReader saxReader=new SAXReader();
		XMLWriter xmlWriter=new XMLWriter(out);
		return out.toString();
		/* The following is the JAXP way, which mysteriously totally botches entities that contain 
		 * embedded XML 
		StringWriter out=new StringWriter((int)file.length() * 4); 
		Transformer transformer=TransformerFactory.newInstance().newTransformer(); 
		XMLReader saxReader=XMLReaderFactory.createXMLReader(); 
Stop searching for code, let great code find you!  Add Codota to your java IDE