private static void readCorrectLine() throws CsvErrorsExceededException { // With a Correct line String correctLine = "Sumo,Bichon Maltais,Bernadette Chirac"; InputStream stream = new StringStream(HEADER + "\n" + correctLine); // No exception for that case System.out.println("**************"); System.out.println("validation with no error"); System.out.println("**************"); for (DogValid dog : engine.parseInputStream(stream, DogValid.class).getObjects()) { System.out.println(dog); } System.out.println(); }
private static void readIncorrectLine() { // With an incorrect line // Not name, // Bad race // Too long proprietary String incorrectLine = ",Bad Race,Bad proprietary"; InputStream stream = new StringStream(HEADER + "\n" + incorrectLine); System.out.println("**************"); System.out.println("validation with an incorrect line"); System.out.println("**************"); try { engine.parseInputStream(stream, DogValid.class).getObjects(); } catch (CsvErrorsExceededException errors) { System.out.println("Exception message : " + errors.getMessage()); for (Error error : errors.getErrors()) { System.out.println("CsvLine : " + error.getCsvLine()); for (String message : error.getMessages()) { System.out.println("\t" + message); } } } System.out.println(); }