1 9 10 package org.dom4j.samples.performance; 11 12 import java.io.BufferedReader ; 13 import java.io.FileReader ; 14 import java.io.StringReader ; 15 16 import org.dom4j.Document; 17 import org.dom4j.io.SAXReader; 18 19 25 public class ParseTest extends PerformanceSupport { 26 27 private int bufferSize = 128 * 1024; 28 29 private Document document; 30 31 private SAXReader xmlReader; 32 33 private String text; 34 35 public static void main(String [] args) { 36 run(new ParseTest(), args); 37 } 38 39 public ParseTest() { 40 } 41 42 protected void setUp() throws Exception { 43 xmlReader = new SAXReader(); 44 45 StringBuffer buffer = new StringBuffer (64 * 1024); 46 BufferedReader reader = new BufferedReader (new FileReader (xmlFile)); 47 while (true) { 48 String text = reader.readLine(); 49 if (text == null) { 50 break; 51 } 52 buffer.append(text); 53 buffer.append("\n"); 54 } 55 text = buffer.toString(); 56 } 57 58 protected void tearDown() throws Exception { 59 println("Created Document: " + document); 60 } 61 62 protected Task createTask() throws Exception { 63 return new Task() { 64 public void run() throws Exception { 65 document = xmlReader.read(new StringReader (text)); 66 } 67 }; 68 } 69 } 70 71 109 | Popular Tags |