1 9 10 package org.dom4j.samples.performance; 11 12 import java.io.StringWriter ; 13 14 import org.dom4j.Document; 15 import org.dom4j.io.SAXReader; 16 import org.dom4j.io.XMLWriter; 17 18 24 public class ToTextTest extends PerformanceSupport { 25 26 private int bufferSize = 128 * 1024; 27 28 private Document document; 29 30 private XMLWriter xmlWriter; 31 32 private StringWriter stringWriter; 33 34 public static void main(String [] args) { 35 run(new ToTextTest(), args); 36 } 37 38 public ToTextTest() { 39 } 40 41 protected void setUp() throws Exception { 42 SAXReader reader = new SAXReader(); 43 document = reader.read(xmlFile); 44 stringWriter = new StringWriter (bufferSize); 45 xmlWriter = new XMLWriter(stringWriter); 46 } 47 48 protected void tearDown() throws Exception { 49 println("Created text representation of: " 50 + stringWriter.getBuffer().length() + " characters"); 51 } 52 53 protected Task createTask() throws Exception { 54 return new Task() { 55 public void run() throws Exception { 56 stringWriter.getBuffer().setLength(0); 57 xmlWriter.write(document); 58 } 59 }; 60 } 61 } 62 63 101 | Popular Tags |