With white space:
import org.jdom.*; import org.jdom.output.XMLOutputter; public class HelloJDOM2 { public static void main(String[] args) { Element root = new Element("GREETING"); root.setText("\r\n Hello JDOM!\r\n"); Document doc = new Document(root); // At this point the document only exists in memory. // We still need to serialize it XMLOutputter outputter = new XMLOutputter(); try { outputter.output(doc, System.out); } catch (Exception e) { System.err.println(e); } } }