Package java.io

Examples of java.io.Writer


     *
     * @see de.netseeker.ejoe.adapter.SerializeAdapter#write(java.lang.Object, java.io.OutputStream)
     */
    public void write( Object obj, OutputStream out ) throws Exception
    {
        Writer writer = new OutputStreamWriter( out, EJConstants.EJOE_DEFAULT_CHARSET );
        Marshaller marshaller = new Marshaller( writer );
        try
        {
            if ( _mapping != null )
            {
View Full Code Here


     *
     * @see de.netseeker.ejoe.adapter.SerializeAdapter#write(java.lang.Object, java.io.OutputStream)
     */
    public void write( Object obj, OutputStream out ) throws Exception
    {
        Writer writer = new OutputStreamWriter( out, "UTF-8" );
        writer.write( obj.toString() );
        writer.close();
    }
View Full Code Here

// This test assumes that the Apache Commons Lang implementation of HtmlEscapeHandler is used.

public class StringEscapeUtilsTest extends TestCase {

  public void testLessThan() throws IOException {
    Writer sb = new WriteBuffer();
    HtmlCanvas.HTML_ESCAPE_HANDLER.escapeXml(sb, "a<b");
    assertEquals("a&lt;b", sb.toString());
  }
View Full Code Here

    }

    @Test
    public void testBadWrite() throws IOException {
        File tempXMLFile = getWAXTempXMLFile();
        Writer fw = new FileWriter(tempXMLFile.getAbsolutePath());
        WAX wax = new WAX(fw);
        try {
            wax.start("root");
            fw.close(); // closed the Writer instead of allowing WAX to do it
        }
        finally {
            boolean success = tempXMLFile.delete();
            assertTrue(success);
        }
View Full Code Here

    }

    private void createMappingFile(TreeMap<String, String> uriMap) {
        try {
            FileObject fo = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT,"",CONFIG_PROPERTIES);
            Writer w = fo.openWriter();
            for (String uri : uriMap.keySet()) {
                w.append(uri);
                w.append("=");
                w.append(uriMap.get(uri));
                w.append('\n');
            }
            w.close();
        } catch (IOException ex) {
            LOG.log(Level.WARNING, "Unable to create mapping file", ex);
        }
    }
View Full Code Here

        c.img().src("plaatje.png").alt("plaatje").div().text("txt")._()._();
    }

    public void testBuilder() throws IOException {
        long now = System.currentTimeMillis();
        Writer pw = new PrintWriter(new StringWriter());
        for (int i = 0; i < 100000; i++) {
            StringBuilder sb = new StringBuilder(32);
            sb.append("Hello World, Here I comeHello World, Here I comeHello World, Here I come");
            pw.append(sb.toString());
        }
        long ms = System.currentTimeMillis();
        System.out.println("1=" + (ms - now));
    }
View Full Code Here

        System.out.println("1=" + (ms - now));
    }

    public void testBuilder2() throws IOException {
        long now = System.currentTimeMillis();
        Writer pw = new PrintWriter(new StringWriter());
        for (int i = 0; i < 100000; i++) {
            StringBuilder sb = new StringBuilder(64);
            sb.append("Hello World, Here I comeHello World, Here I comeHello World, Here I come");
            pw.append(sb.toString());
        }
        long ms = System.currentTimeMillis();
        System.out.println("2=" + (ms - now));
    }
View Full Code Here

        System.out.println("2=" + (ms - now));
    }

    public void testBuilder3() throws IOException {
        long now = System.currentTimeMillis();
        Writer pw = new PrintWriter(new StringWriter());
        for (int i = 0; i < 100000; i++) {
            StringBuilder sb = new StringBuilder(256);
            sb.append("Hello World, Here I comeHello World, Here I comeHello World, Here I come");
            pw.append(sb);
        }
        long ms = System.currentTimeMillis();
        System.out.println("3=" + (ms - now));
    }
View Full Code Here

        long ms = System.currentTimeMillis();
        System.out.println("3=" + (ms - now));
    }
    public void testBuilder4() throws IOException {
        long now = System.currentTimeMillis();
        Writer pw = new PrintWriter(new StringWriter());
        for (int i = 0; i < 100000; i++) {
            StringBuilder sb = threadLocalBuilder.get();
            sb.append("Hello World, Here I comeHello World, Here I comeHello World, Here I come");
            pw.append(sb);
        }
        long ms = System.currentTimeMillis();
        System.out.println("4=" + (ms - now));
    }   
View Full Code Here

        {
            init(new WriterToASCI(output), format, defaultProperties, true);
        }
        else
        {
            Writer osw;

            try
            {
                osw = Encodings.getWriter(output, encoding);
            }
View Full Code Here

TOP

Related Classes of java.io.Writer

Copyright © 2015 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.