public String toString(final Reflections reflections) { Document document = createDocument(reflections); try { StringWriter writer = new StringWriter(); XMLWriter xmlWriter = new XMLWriter(writer, OutputFormat.createPrettyPrint()); xmlWriter.write(document); xmlWriter.close(); return writer.toString(); } catch (IOException e) { throw new RuntimeException(); } }
public String toString(final Reflections reflections) { Document document = createDocument(reflections); try { StringWriter writer = new StringWriter(); XMLWriter xmlWriter = new XMLWriter(writer, OutputFormat.createPrettyPrint()); xmlWriter.write(document); xmlWriter.close(); return writer.toString(); } catch (IOException e) { throw new RuntimeException(); } }
public File save(final Reflections reflections, final String filename) { File file = Utils.prepareFile(filename); try { Document document = createDocument(reflections); XMLWriter xmlWriter = new XMLWriter(new FileOutputStream(file), OutputFormat.createPrettyPrint()); xmlWriter.write(document); xmlWriter.close(); } catch (IOException e) { throw new ReflectionsException("could not save to file " + filename, e); } catch (Throwable e) { throw new RuntimeException("Could not save to file " + filename + ". Make sure relevant dependencies exist on classpath.", e); } return file; }
public File save(final Reflections reflections, final String filename) { File file = Utils.prepareFile(filename); try { Document document = createDocument(reflections); XMLWriter xmlWriter = new XMLWriter(new FileOutputStream(file), OutputFormat.createPrettyPrint()); xmlWriter.write(document); xmlWriter.close(); } catch (IOException e) { throw new ReflectionsException("could not save to file " + filename, e); } catch (Throwable e) { throw new RuntimeException("Could not save to file " + filename + ". Make sure relevant dependencies exist on classpath.", e); } return file; }
@SuppressFBWarnings("DM_EXIT") public static void main(String[] args) throws Exception { if (args.length != 2) { System.err.println("Usage: " + AddMessages.class.getName() + " <input collection> <output collection>"); System.exit(1); } // Load plugins, in order to get message files DetectorFactoryCollection.instance(); String inputFile = args[0]; String outputFile = args[1]; Project project = new Project(); SortedBugCollection inputCollection = new SortedBugCollection(project); inputCollection.readXML(inputFile); Document document = inputCollection.toDocument(); AddMessages addMessages = new AddMessages(inputCollection, document); addMessages.execute(); XMLWriter writer = new XMLWriter(new BufferedOutputStream(new FileOutputStream(outputFile)), OutputFormat.createPrettyPrint()); writer.write(document); writer.close(); } }
writer.close(); text.setText(out.getBuffer().toString()); } catch (DocumentException e) {
final XMLWriter docWriter = new XMLWriter(os); docWriter.write(incXmlDoc); docWriter.close(); } finally { Utils.closeQuietly(os);
/** * 把document对象写入新的文件 * * @param document * @throws Exception */ public static void writer(Document document, OutputStreamWriter outputStream, String encoding) throws Exception { OutputFormat format = OutputFormat.createPrettyPrint(); format.setEncoding(encoding); XMLWriter writer = new XMLWriter(outputStream, format); writer.write(document); writer.flush(); writer.close(); }
XMLWriter writer=new XMLWriter(out,format); writer.write(doc); writer.close(); out.close(); }catch(Exception ex){
XMLWriter writer = new XMLWriter( new FileWriter( new File( data.filename ) ), format ); writer.write( data.document ); writer.close(); } catch ( Exception e ) {
protected void writeXmlDocument( File file, Document document ) throws IOException { XMLWriter writer = new IdeaXmlWriter( file ); writer.write( document ); writer.close(); }
public void write(Writer writer) throws IOException { OutputFormat format = OutputFormat.createPrettyPrint(); XMLWriter output = new XMLWriter(writer, format); output.write(document); output.close(); } }
private void writeDbConfigXml(final File dbConfigXml, final Document dbConfigDoc) throws IOException { // write dbconfig.xml try (FileOutputStream fos = new FileOutputStream(dbConfigXml)) { XMLWriter writer = new XMLWriter(fos, OutputFormat.createPrettyPrint()); writer.write(dbConfigDoc); writer.close(); } }
public String toString(final Reflections reflections) { Document document = createDocument(reflections); try { StringWriter writer = new StringWriter(); XMLWriter xmlWriter = new XMLWriter(writer , OutputFormat.createPrettyPrint()); xmlWriter.write(document); xmlWriter.close(); return writer.toString(); } catch (IOException e) { throw new RuntimeException(); } }
@Test public void dom4j() throws DocumentException, IOException { String absolutePath = Paths.get(PATH_TO_XML).toAbsolutePath().toString(); SAXReader reader = new SAXReader(); Document document = reader.read(absolutePath); Node node = document.selectSingleNode(XPATH_TO_NODE); node.detach(); XMLWriter writer = new XMLWriter(new FileWriter(absolutePath), OutputFormat.createPrettyPrint()); writer.write(document); writer.close(); }
private void saveModel() throws IOException { final XMLWriter writer = new XMLWriter(new FileWriter(file), OutputFormat.createPrettyPrint()); writer.setEscapeText(false); writer.write(document); writer.close(); }
Document document = node.getDocument(); node.detach(); XMLWriter writer = new XMLWriter(new FileWriter(document.getPath() + document.getName()), OutputFormat.createPrettyPrint()); writer.write(document); writer.close();
public void testBug1119733() throws Exception { Document doc = DocumentHelper .parseText("<root><code>foo</code> bar</root>"); StringWriter out = new StringWriter(); XMLWriter writer = new XMLWriter(out, OutputFormat.createPrettyPrint()); writer.write(doc); writer.close(); String xml = out.toString(); System.out.println(xml); assertEquals("whitespace problem", -1, xml.indexOf("</code>bar")); }
protected void testEncoding(String encoding) throws Exception { ByteArrayOutputStream out = new ByteArrayOutputStream(); OutputFormat format = OutputFormat.createPrettyPrint(); format.setEncoding(encoding); XMLWriter writer = new XMLWriter(out, format); writer.write(document); writer.close(); log("Wrote to encoding: " + encoding); }
public void testRussian2() throws Exception { Document doc = getDocument("/xml/russArticle.xml"); XMLWriter xmlWriter = new XMLWriter(new OutputFormat("", false, "koi8-r")); ByteArrayOutputStream out = new ByteArrayOutputStream(); xmlWriter.setOutputStream(out); xmlWriter.write(doc); xmlWriter.flush(); xmlWriter.close(); log(out.toString()); }