Code example for StringWriter

Methods: closetoString

0
	 */ 
	public static String fromJSONtoXML(String json) {
		HierarchicalStreamDriver driver = new JettisonMappedXmlDriver();
		StringReader reader = new StringReader(json);
		HierarchicalStreamReader hsr = driver.createReader(reader);
		StringWriter writer = new StringWriter();
		try { 
			new HierarchicalStreamCopier().copy(hsr, new PrettyPrintWriter(
					writer));
			return writer.toString();
		} finally { 
			if (writer != null) {
				try { 
					writer.close();
				} catch (IOException e) {
					// ignore 
				} 
			} 
		} 
	}