프로그램/Java
[Java] JDom – XMLOutputter 를 이용한 Document 객체 출력
로드러너
2013. 11. 15. 02:30
작성된 XML Document 객체를 다양한 형태로 출력할 수 있다.
…
Document doc new Document();
…
// Document 객체 작성
…
XMLOutputter xo = new XMLOutputter();
// 1) Document 객체를 표준출력으로 보낸다.
xo.output(doc, System.out);
// 2) Document 객체를 파일로 보낸다.
xo.output(doc, new FileOutputStream(“XML파일”));
xo.output(doc, new FileWriter(“XML파일”));
// 3) Document 객체를 소켓 OutputStream 으로 보낸다.
os = new DataOutputStream(소켓.getOutputStream());
xo.output(doc, os);
// 4) Document 객체를 String 으로 보낸다.
XMLOutputtr xo = new XMLOutputter();
String str = xo.output(Document doc);