Csv { public static CsvReader readerNoBOM(final PushbackReader reader) { return CSV.readerNoBOM(reader); } private  Csv(); static String[] readSystemProperty(final String propertyName, final String... defaults); static void writeCsvRow(final Appendable writer, final Object... elems); static void writeCsvRow2(final Appendable writer, final Object obj, final Object... elems); static void writeCsvRow(final Appendable writer, final long... elems); static void writeCsvRowNoEOL(final long[] elems, final Appendable writer); static void writeCsvRow(final Appendable writer, final Iterable<?> elems); static void writeCsvRowNoEOL(final Iterable<?> elems, final Appendable writer); static T read(final File file, final Charset charset,
          final CsvMapHandler<T> handler); static T read(final File file, final Charset charset,
          final CsvHandler<T> handler); static List<Map<String, String>> read(final Reader preader); static T read(final Reader preader,
          final CsvMapHandler<T> handler); static List<String> readRow(final String row); static List<String> readRow(final Reader reader); static T readRow(final Reader reader, final CsvRowHandler<T> handler); static T read(final Reader preader,
          final CsvHandler<T> handler); static T readNoBom(final PushbackReader reader, final CsvHandler<T> handler); static Iterable<Iterable<String>> asIterable(final Reader preader); static CsvReader reader(final Reader preader); static CsvReader readerNoBOM(final PushbackReader reader); static void writeCsvElement(final CharSequence elem, final Appendable writer); static void writeQuotedCsvElement(final CharSequence elem, final Appendable writer); static CharSequence toCsvElement(final CharSequence elem); @CheckReturnValue static int readCsvElement(final Reader reader, final StringBuilder addElemTo); static final CharSeparatedValues CSV; }
@Test public void testCsvStream1() throws IOException, CsvParseException { CsvReader reader = Csv.readerNoBOM(new PushbackReader(new StringReader(""))); Assert.assertEquals(TokenType.ELEMENT, reader.next()); Assert.assertEquals("", reader.getElement().toString()); Assert.assertEquals(TokenType.END_ROW, reader.next()); Assert.assertEquals(TokenType.END_DOCUMENT, reader.next()); Assert.assertEquals(TokenType.END_DOCUMENT, reader.next()); }
@Test public void testCsvStream1n1() throws IOException, CsvParseException { CsvReader reader = Csv.readerNoBOM(new PushbackReader(new StringReader(","))); Assert.assertEquals(TokenType.ELEMENT, reader.next()); Assert.assertEquals("", reader.getElement().toString()); Assert.assertEquals(TokenType.ELEMENT, reader.next()); Assert.assertEquals("", reader.getElement().toString()); Assert.assertEquals(TokenType.END_ROW, reader.next()); Assert.assertEquals(TokenType.END_DOCUMENT, reader.next()); Assert.assertEquals(TokenType.END_DOCUMENT, reader.next()); }
@Test public void testCsvStream2() throws IOException, CsvParseException { CsvReader reader = Csv.readerNoBOM(new PushbackReader(new StringReader("bla"))); Assert.assertEquals(TokenType.ELEMENT, reader.next()); Assert.assertEquals("bla", reader.getElement().toString()); Assert.assertEquals(TokenType.END_ROW, reader.next()); Assert.assertEquals(TokenType.END_DOCUMENT, reader.next()); Assert.assertEquals(TokenType.END_DOCUMENT, reader.next()); }
@Test public void testCsvStream3() throws IOException, CsvParseException { CsvReader reader = Csv.readerNoBOM(new PushbackReader(new StringReader("\"bla\""))); Assert.assertEquals(TokenType.ELEMENT, reader.next()); Assert.assertEquals("bla", reader.getElement().toString()); Assert.assertEquals(TokenType.END_ROW, reader.next()); Assert.assertEquals(TokenType.END_DOCUMENT, reader.next()); Assert.assertEquals(TokenType.END_DOCUMENT, reader.next()); }
@Test public void testCsvStream4() throws IOException, CsvParseException { CsvReader reader = Csv.readerNoBOM(new PushbackReader(new StringReader("bla,\"bla\"\n"))); Assert.assertEquals(TokenType.ELEMENT, reader.next()); Assert.assertEquals("bla", reader.getElement().toString()); Assert.assertEquals(TokenType.ELEMENT, reader.next()); Assert.assertEquals("bla", reader.getElement().toString()); Assert.assertEquals(TokenType.END_ROW, reader.next()); Assert.assertEquals(TokenType.END_DOCUMENT, reader.next()); Assert.assertEquals(TokenType.END_DOCUMENT, reader.next()); }