Refine search
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(); } }
private static void dump(Document document) { if ( !log.isTraceEnabled() ) { return; } final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final Writer w = new PrintWriter( baos ); try { final XMLWriter xw = new XMLWriter( w, new OutputFormat( " ", true ) ); xw.write( document ); w.flush(); } catch (IOException e1) { throw new RuntimeException( "Error dumping enhanced class", e1 ); } log.tracef( "Envers-generate entity mapping -----------------------------\n%s", baos.toString() ); log.trace( "------------------------------------------------------------" ); } }
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(); } }
public static String getText(Document document, String charset) throws IOException, UnsupportedEncodingException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); OutputFormat outputFormat = new OutputFormat(" ", true, charset); try { XMLWriter writer = new XMLWriter(baos, outputFormat); writer.write(document); baos.flush(); } catch (UnsupportedEncodingException e) { throw e; } catch (IOException e) { throw e; } finally { if (baos != null) { baos.close(); } } return baos.toString(charset); } }
public String asXML() { try { StringWriter out = new StringWriter(); XMLWriter writer = new XMLWriter(out, new OutputFormat()); writer.write(this); writer.flush(); return out.toString(); } catch (IOException e) { throw new RuntimeException("IOException while generating " + "textual representation: " + e.getMessage()); } }
public String asXML() { OutputFormat format = new OutputFormat(); format.setEncoding(encoding); try { StringWriter out = new StringWriter(); XMLWriter writer = new XMLWriter(out, format); writer.write(this); writer.flush(); return out.toString(); } catch (IOException e) { throw new RuntimeException("IOException while generating textual " + "representation: " + e.getMessage()); } }
private static void writeDocument(Document doc, OutputStream stream) throws IOException { String charset = "UTF-8"; Writer writer = new OutputStreamWriter(stream, charset); OutputFormat format = new OutputFormat(); format.setEncoding(charset); XMLWriter xmlWriter = new XMLWriter(writer, format); xmlWriter.write(doc); xmlWriter.flush(); }
private static void writeDocument(Document doc, OutputStream stream) throws IOException { String charset = "UTF-8"; Writer writer = new OutputStreamWriter(stream, charset); OutputFormat format = new OutputFormat(); format.setEncoding(charset); XMLWriter xmlWriter = new XMLWriter(writer, format); xmlWriter.write(doc); xmlWriter.flush(); }
private static void writeDocument(Document doc, OutputStream stream) throws IOException { String charset = "UTF-8"; Writer writer = new OutputStreamWriter(stream, charset); OutputFormat format = new OutputFormat(); format.setEncoding(charset); XMLWriter xmlWriter = new XMLWriter(writer, format); xmlWriter.write(doc); xmlWriter.flush(); }