Examples of CsvWriter


Examples of com.csvreader.CsvWriter

  @Test
  public void test71() throws Exception {
    byte[] buffer;

    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    CsvWriter writer = new CsvWriter(stream, ',', Charset
        .forName("ISO-8859-1"));
    writer.setForceQualifier(true);
    writer.write(" data ");
    writer.endRecord();
    writer.close();

    buffer = stream.toByteArray();
    stream.close();

    String data = Charset.forName("ISO-8859-1").decode(
View Full Code Here

Examples of com.csvreader.CsvWriter

  @Test
  public void test72() throws Exception {
    byte[] buffer;

    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    CsvWriter writer = new CsvWriter(stream, ',', Charset
        .forName("ISO-8859-1"));
    Assert.assertEquals('\0', writer.getRecordDelimiter());
    writer.setRecordDelimiter(';');
    Assert.assertEquals(';', writer.getRecordDelimiter());
    writer.write("a;b");
    writer.endRecord();
    writer.close();

    buffer = stream.toByteArray();
    stream.close();

    String data = Charset.forName("ISO-8859-1").decode(
View Full Code Here

Examples of com.csvreader.CsvWriter

  @Test
  public void test73() throws Exception {
    byte[] buffer;

    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    CsvWriter writer = new CsvWriter(stream, ',', Charset
        .forName("ISO-8859-1"));
    Assert.assertEquals(CsvWriter.ESCAPE_MODE_DOUBLED, writer
        .getEscapeMode());
    writer.setEscapeMode(CsvWriter.ESCAPE_MODE_BACKSLASH);
    Assert.assertEquals(CsvWriter.ESCAPE_MODE_BACKSLASH, writer
        .getEscapeMode());
    writer.write("1,2");
    writer.write("3");
    writer.write("blah \"some stuff in quotes\"");
    writer.endRecord();
    writer.setForceQualifier(true);
    writer.write("1,2");
    writer.write("3");
    writer.write("blah \"some stuff in quotes\"");
    writer.close();

    buffer = stream.toByteArray();
    stream.close();

    String data = Charset.forName("ISO-8859-1").decode(
View Full Code Here

Examples of com.csvreader.CsvWriter

  @Test
  public void test74() throws Exception {
    byte[] buffer;

    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    CsvWriter writer = new CsvWriter(stream, ',', Charset
        .forName("ISO-8859-1"));
    writer.setEscapeMode(CsvWriter.ESCAPE_MODE_BACKSLASH);
    writer.setUseTextQualifier(false);
    writer.write("1,2");
    writer.write("3");
    writer.write("blah \"some stuff in quotes\"");
    writer.endRecord();
    writer.close();

    buffer = stream.toByteArray();
    stream.close();

    String data = Charset.forName("ISO-8859-1").decode(
View Full Code Here

Examples of com.csvreader.CsvWriter

  @Test
  public void test75() throws Exception {
    byte[] buffer;

    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    CsvWriter writer = new CsvWriter(stream, ',', Charset
        .forName("ISO-8859-1"));
    writer.write("1");
    writer.endRecord();
    writer.writeComment("blah");
    writer.write("2");
    writer.endRecord();
    writer.close();

    buffer = stream.toByteArray();
    stream.close();

    String data = Charset.forName("ISO-8859-1").decode(
View Full Code Here

Examples of com.csvreader.CsvWriter

    reader.close();
  }

  @Test
  public void test87() throws Exception {
    CsvWriter writer = new CsvWriter("temp.csv");
    writer.write("1");
    writer.close();

    CsvReader reader = new CsvReader("temp.csv");
    Assert.assertTrue(reader.readRecord());
    Assert.assertEquals("1", reader.get(0));
    Assert.assertEquals(1, reader.getColumnCount());
View Full Code Here

Examples of com.dotcms.repackage.com.csvreader.CsvWriter

    private File generateFoldersToCheckCSV(String outputFile) throws DotDataException, IOException {
        Connection conn = DbConnectionFactory.getConnection();
        ResultSet rs = null;
        PreparedStatement statement = null;
        CsvWriter writer = null;
        File csvFile = null;

        try {
            csvFile = new File(outputFile);
            writer = new CsvWriter(new FileWriter(csvFile, true), '|');
            statement = conn.prepareStatement("select f.inode, f.identifier, i.parent_path, i.asset_name, i.host_inode from folder f join identifier i on f.identifier = i.id ");
      rs = statement.executeQuery();
            int count = 0;

            while (rs.next()) {
                writer.write(rs.getString("inode"));
                writer.write(rs.getString("identifier"));
                writer.write(rs.getString("parent_path"));
                writer.write(rs.getString("asset_name"));
                writer.write(rs.getString("host_inode"));
                writer.endRecord();
                count++;

                if(count==1000) {
                    writer.flush();
                    count = 0;
                }
            }

        } catch (SQLException e) {
            throw new DotDataException(e.getMessage(),e);
        }finally {
            try { if (rs != null) rs.close(); } catch (Exception e) { }
            try { if ( statement!= null ) statement.close(); } catch (Exception e) { }
            if(writer!=null) writer.close();

        }

        return csvFile;
View Full Code Here

Examples of com.fasterxml.jackson.dataformat.csv.impl.CsvWriter

    public CsvGenerator(IOContext ctxt, int jsonFeatures, int csvFeatures,
            ObjectCodec codec, Writer out,
            char columnSeparator, char quoteChar, char[] linefeed)
    {
        this(ctxt, jsonFeatures, csvFeatures, codec,
                new CsvWriter(ctxt, csvFeatures, out, columnSeparator, quoteChar, linefeed));
    }
View Full Code Here

Examples of com.griddynamics.gridkit.coherence.patterns.benchmark.csv.CSVWriter

    List<Integer> callerCountList = new ArrayList<Integer>();
    for(String callerCount : getProperty("benchmark.command.callerCount").split(":"))
      callerCountList.add(Integer.parseInt(callerCount));
   
    setSysProp("benchmark.output.file", "matrixRunCommandBenchmark.csv");
    csvWriter = new CSVWriter(getProperty("benchmark.output.file"));
   
    setSysProp("benchmark.output.aheader", "");
    setSysProp("benchmark.output.avalues", "");
   
    aheader = getProperty("benchmark.output.aheader");
View Full Code Here

Examples of com.serotonin.m2m2.view.export.CsvWriter

/**
* @author Matthew Lohbihler
*/
public class UserCommentCsvStreamer {
    public UserCommentCsvStreamer(PrintWriter out, List<ReportUserComment> comments, Translations translations) {
        CsvWriter csvWriter = new CsvWriter();
        String[] data = new String[5];

        // Write the headers.
        data[0] = translations.translate("users.username");
        data[1] = translations.translate("reports.commentList.type");
        data[2] = translations.translate("reports.commentList.typeKey");
        data[3] = translations.translate("reports.commentList.time");
        data[4] = translations.translate("notes.note");
        out.write(csvWriter.encodeRow(data));

        for (ReportUserComment comment : comments) {
            data[0] = comment.getUsername();
            if (data[0] == null)
                data[0] = translations.translate("common.deleted");
            if (comment.getCommentType() == UserComment.TYPE_EVENT) {
                data[1] = translations.translate("reports.commentList.type.event");
                data[2] = Integer.toString(comment.getTypeKey());
            }
            else if (comment.getCommentType() == UserComment.TYPE_POINT) {
                data[1] = translations.translate("reports.commentList.type.point");
                data[2] = comment.getPointName();
            }
            else {
                data[1] = translations.translate("common.unknown");
                data[2] = "";
            }

            data[3] = comment.getPrettyTime();
            data[4] = comment.getComment();

            out.write(csvWriter.encodeRow(data));
        }

        out.flush();
        out.close();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.