Java 8 StringWriter - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 StringWriter class.

This code example shows how to use the following methods: toString
        final String original = toString(fileName);
 
        final InputStream is = getResource(fileName);
        final BundledPatch patch = PatchBundleXml.parse(is);
 
        final StringWriter writer = new StringWriter();
        PatchBundleXml.marshal(writer, patch);
        final String marshalled = writer.toString();
 
        System.out.println(original);
        System.out.println(marshalled);
 
        XMLUtils.compareXml(original, marshalled, false);
    } 
 
    static InputStream getResource(final String name) throws IOException {
        final URL resource = PatchBundleXmlUnitTestCase.class.getClassLoader().getResource(name);
        assertNotNull(name, resource);
        return resource.openStream();
    } 
Full Snippet Info
10
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: toString, write
    private static final Formatter THE_FORMATTER = new Formatter() {
        @Override 
        public String format(LogRecord r) { 
            Throwable thrown = r.getThrown(); 
            if (thrown != null) { 
                StringWriter sw = new StringWriter(); 
                PrintWriter pw = new PrintWriter(sw); 
                sw.write(r.getMessage()); 
                sw.write("\n"); 
                thrown.printStackTrace(pw); 
                pw.flush(); 
                return sw.toString(); 
            } else { 
                return r.getMessage(); 
            } 
        } 
    }; 
 
    /** 
     * Constructs a new instance of the Android log handler. 
Full Snippet Info
10
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: toString
 
	@Override 
	public boolean onException(Object obj, Throwable e)
	{ 
		// log, but ignore exceptions 
		StringWriter stringWriter = new StringWriter();
		PrintWriter printWriter = new PrintWriter(stringWriter);
		e.printStackTrace(printWriter);
		exceptions.put(obj.toString(), stringWriter.toString());
		return true; 
	} 
} 
Full Snippet Info
10
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: toString
	 * @see org.springframework.mail.MailPreparationException 
	 */ 
	public static String processTemplateIntoString(Template template, Object model)
			throws IOException, TemplateException {
 
		StringWriter result = new StringWriter();
		template.process(model, result);
		return result.toString();
	} 
 
} 
Full Snippet Info
9
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: toString
        final String original = toString(fileName);
 
        final InputStream is = getResource(fileName);
        final Patch patch = PatchXml.parse(is).resolvePatch(null, null);
 
        final StringWriter writer = new StringWriter();
        PatchXml.marshal(writer, patch);
        final String marshalled = writer.toString();
 
        XMLUtils.compareXml(original, marshalled, false);
    } 
 
    static InputStream getResource(String name) throws IOException {
        final URL resource = PatchXmlUnitTestCase.class.getClassLoader().getResource(name);
        assertNotNull(name, resource);
        return resource.openStream();
    } 
 
    private String toString(String fileName) throws Exception {
        final InputStream is = getResource(fileName);
Full Snippet Info
10
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Java 8 StringWriter Questions & Answers:

See Code Examples for Java 8 StringWriter Methods: