use of org.spf4j.io.csv.CsvReader in project spf4j by zolyfarkas.
the class CsvTest method testCsvStream1n1.
@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());
}
use of org.spf4j.io.csv.CsvReader in project spf4j by zolyfarkas.
the class CsvTest method testCsvStream4.
@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());
}
use of org.spf4j.io.csv.CsvReader in project spf4j by zolyfarkas.
the class CsvTest method testCsvStream5.
@Test
public void testCsvStream5() throws IOException, CsvParseException {
CsvReader reader = Csv.reader(new StringReader("bla,\"bla\"\nuhu,uhu2\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.ELEMENT, reader.next());
Assert.assertEquals("uhu", reader.getElement().toString());
Assert.assertEquals(TokenType.ELEMENT, reader.next());
Assert.assertEquals("uhu2", reader.getElement().toString());
Assert.assertEquals(TokenType.END_ROW, reader.next());
Assert.assertEquals(TokenType.END_DOCUMENT, reader.next());
Assert.assertEquals(TokenType.END_DOCUMENT, reader.next());
}
use of org.spf4j.io.csv.CsvReader in project spf4j by zolyfarkas.
the class CsvTest method testCsvFileParsingReader2.
@Test
public void testCsvFileParsingReader2() throws IOException, CsvParseException {
try (InputStream resourceAsStream = CsvTest.class.getResourceAsStream("/test.csv")) {
CsvReader reader = Csv.reader(new InputStreamReader(resourceAsStream, StandardCharsets.UTF_8));
CsvReader.TokenType token;
while ((token = reader.next()) != TokenType.END_DOCUMENT) {
LOG.debug("Token {}", token);
}
Assert.assertNotNull(reader);
}
}
use of org.spf4j.io.csv.CsvReader in project spf4j by zolyfarkas.
the class CsvTest method testCsvStream1.
@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());
}
Aggregations