Package com.csvreader

Examples of com.csvreader.CsvReader


  }

  @Test
  public void test90() throws Exception {
    try {
      CsvReader reader = new CsvReader((Reader) null, ',');
    } catch (Exception ex) {
      assertException(new IllegalArgumentException(
          "Parameter inputStream can not be null."), ex);
    }
  }
View Full Code Here


    writer.close();

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

    CsvReader reader = new CsvReader(new ByteArrayInputStream(buffer),
        Charset.forName("ISO-8859-1"));
    reader.readRecord();
    Assert.assertEquals(test, reader.get(0));
    reader.close();
  }
View Full Code Here

    writer.close();

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

    CsvReader reader = new CsvReader(new ByteArrayInputStream(buffer), ',',
        Charset.forName("ISO-8859-1"));
    reader.readRecord();
    Assert.assertEquals(test, reader.get(0));
    reader.close();
  }
View Full Code Here

    Assert.assertEquals("\"1,\\\\2\"\r\n", data);
  }

  @Test
  public void test135() throws Exception {
    CsvReader reader = CsvReader.parse("1\n\n1\r\r1\r\n\r\n1\n\r1");
    Assert.assertTrue(reader.getSkipEmptyRecords());
    reader.setSkipEmptyRecords(false);
    Assert.assertFalse(reader.getSkipEmptyRecords());
    Assert.assertTrue(reader.readRecord());
    Assert.assertEquals(1, reader.getColumnCount());
    Assert.assertEquals("1", reader.get(0));
    Assert.assertEquals(0L, reader.getCurrentRecord());
    Assert.assertTrue(reader.readRecord());
    Assert.assertEquals(1, reader.getColumnCount());
    Assert.assertEquals("", reader.get(0));
    Assert.assertEquals(1L, reader.getCurrentRecord());
    Assert.assertTrue(reader.readRecord());
    Assert.assertEquals(1, reader.getColumnCount());
    Assert.assertEquals("1", reader.get(0));
    Assert.assertEquals(2L, reader.getCurrentRecord());
    Assert.assertTrue(reader.readRecord());
    Assert.assertEquals(1, reader.getColumnCount());
    Assert.assertEquals("", reader.get(0));
    Assert.assertEquals(3L, reader.getCurrentRecord());
    Assert.assertTrue(reader.readRecord());
    Assert.assertEquals(1, reader.getColumnCount());
    Assert.assertEquals("1", reader.get(0));
    Assert.assertEquals(4L, reader.getCurrentRecord());
    Assert.assertTrue(reader.readRecord());
    Assert.assertEquals(1, reader.getColumnCount());
    Assert.assertEquals("", reader.get(0));
    Assert.assertEquals(5L, reader.getCurrentRecord());
    Assert.assertTrue(reader.readRecord());
    Assert.assertEquals(1, reader.getColumnCount());
    Assert.assertEquals("1", reader.get(0));
    Assert.assertEquals(6L, reader.getCurrentRecord());
    Assert.assertTrue(reader.readRecord());
    Assert.assertEquals(1, reader.getColumnCount());
    Assert.assertEquals("", reader.get(0));
    Assert.assertEquals(7L, reader.getCurrentRecord());
    Assert.assertTrue(reader.readRecord());
    Assert.assertEquals(1, reader.getColumnCount());
    Assert.assertEquals("1", reader.get(0));
    Assert.assertEquals(8L, reader.getCurrentRecord());
    Assert.assertFalse(reader.readRecord());
    reader.close();
  }
View Full Code Here

  @Test
  public void test16() throws Exception {
    String data = "\r\r\n1\r";

    CsvReader reader = CsvReader.parse(data);
    reader.setDelimiter('\r');
    Assert.assertTrue(reader.readRecord());
    Assert.assertEquals("", reader.get(0));
    Assert.assertEquals("", reader.get(1));
    Assert.assertEquals("", reader.get(2));
    Assert.assertEquals(0L, reader.getCurrentRecord());
    Assert.assertEquals(3, reader.getColumnCount());
    Assert.assertEquals("\r\r", reader.getRawRecord());
    Assert.assertTrue(reader.readRecord());
    Assert.assertEquals("1", reader.get(0));
    Assert.assertEquals("", reader.get(1));
    Assert.assertEquals(1L, reader.getCurrentRecord());
    Assert.assertEquals(2, reader.getColumnCount());
    Assert.assertEquals("1\r", reader.getRawRecord());
    Assert.assertFalse(reader.readRecord());
    reader.close();
  }
View Full Code Here

  @Test
  public void test17() throws Exception {
    String data = "\"double\"\"\"\"double quotes\"";

    CsvReader reader = CsvReader.parse(data);
    Assert.assertTrue(reader.readRecord());
    Assert.assertEquals("double\"\"double quotes", reader.get(0));
    Assert.assertEquals(0L, reader.getCurrentRecord());
    Assert.assertEquals(1, reader.getColumnCount());
    Assert.assertEquals("\"double\"\"\"\"double quotes\"", reader
        .getRawRecord());
    Assert.assertFalse(reader.readRecord());
    reader.close();
  }
View Full Code Here

  @Test
  public void test18() throws Exception {
    String data = "1\r";

    CsvReader reader = CsvReader.parse(data);
    Assert.assertTrue(reader.readRecord());
    Assert.assertEquals("1", reader.get(0));
    Assert.assertEquals(0L, reader.getCurrentRecord());
    Assert.assertEquals(1, reader.getColumnCount());
    Assert.assertEquals("1", reader.getRawRecord());
    Assert.assertFalse(reader.readRecord());
    reader.close();
  }
View Full Code Here

  @Test
  public void test19() throws Exception {
    String data = "1\r\n";

    CsvReader reader = CsvReader.parse(data);
    Assert.assertTrue(reader.readRecord());
    Assert.assertEquals("1", reader.get(0));
    Assert.assertEquals(0L, reader.getCurrentRecord());
    Assert.assertEquals(1, reader.getColumnCount());
    Assert.assertEquals("1", reader.getRawRecord());
    Assert.assertFalse(reader.readRecord());
    reader.close();
  }
View Full Code Here

  @Test
  public void test20() throws Exception {
    String data = "1\n";

    CsvReader reader = CsvReader.parse(data);
    Assert.assertTrue(reader.readRecord());
    Assert.assertEquals("1", reader.get(0));
    Assert.assertEquals(0L, reader.getCurrentRecord());
    Assert.assertEquals(1, reader.getColumnCount());
    Assert.assertEquals("1", reader.getRawRecord());
    Assert.assertFalse(reader.readRecord());
    reader.close();
  }
View Full Code Here

  @Test
  public void test21() throws Exception {
    String data = "'bob said, ''Hey!''',2, 3 ";

    CsvReader reader = CsvReader.parse(data);
    reader.setTextQualifier('\'');
    Assert.assertTrue(reader.readRecord());
    Assert.assertEquals("bob said, 'Hey!'", reader.get(0));
    Assert.assertEquals("2", reader.get(1));
    Assert.assertEquals("3", reader.get(2));
    Assert.assertEquals(',', reader.getDelimiter());
    Assert.assertEquals(0L, reader.getCurrentRecord());
    Assert.assertEquals(3, reader.getColumnCount());
    Assert
        .assertEquals("'bob said, ''Hey!''',2, 3 ", reader
            .getRawRecord());
    Assert.assertFalse(reader.readRecord());
    reader.close();
  }
View Full Code Here

TOP

Related Classes of com.csvreader.CsvReader

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.