Package com.asakusafw.utils.io.csv

Examples of com.asakusafw.utils.io.csv.CsvWriter


     * @throws Exception if failed
     */
    @Test
    public void simple() throws Exception {
        StringBuilder buf = new StringBuilder();
        CsvWriter writer = new CsvWriter(buf);
        writer.putField("Hello");
        writer.putField("World");
        writer.putEndOfRecord();
        writer.close();

        assertThat(buf.toString(), is("Hello,World\r\n"));
    }
View Full Code Here


     * @throws Exception if failed
     */
    @Test
    public void multiple() throws Exception {
        StringBuilder buf = new StringBuilder();
        CsvWriter writer = new CsvWriter(buf);
        writer.putField("1-1");
        writer.putField("1-2");
        writer.putField("1-3");
        writer.putEndOfRecord();
        writer.putField("2-1");
        writer.putField("2-2");
        writer.putField("2-3");
        writer.putEndOfRecord();
        writer.putField("3-1");
        writer.putField("3-2");
        writer.putField("3-3");
        writer.putEndOfRecord();
        writer.close();

        assertThat(buf.toString(), is("1-1,1-2,1-3\r\n2-1,2-2,2-3\r\n3-1,3-2,3-3\r\n"));
    }
View Full Code Here

     * @throws Exception if failed
     */
    @Test
    public void escape() throws Exception {
        StringBuilder buf = new StringBuilder();
        CsvWriter writer = new CsvWriter(buf);
        writer.putField("Hello, world!");
        writer.putField("He said \"Hello!\".");
        writer.putField("Name:\r\n  Value");
        writer.putEndOfRecord();
        writer.close();

        assertThat(buf.toString(), is("\"Hello, world!\",\"He said \"\"Hello!\"\".\",\"Name:\r\n  Value\"\r\n"));
    }
View Full Code Here

            throw new IOException(MessageFormat.format(
                    "Failed to prepare output: {1} ({0})",
                    KEY_FILE, file));
        }
        return new SummarizeYaessLogSink(
                new CsvWriter(new OutputStreamWriter(new FileOutputStream(file), encoding)),
                filter);
    }
View Full Code Here

TOP

Related Classes of com.asakusafw.utils.io.csv.CsvWriter

Copyright © 2018 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.