In one of the items on Effective Java, he advised that you should always use libraries for the common task instead of re-inventing the wheel and from then I have not looked back. The book is full of best practices and great practical advice from Joshua Bloch, author of the Java Collection framework, and many key classes on java.lang package. You can even use it to directly convert the CSV data into Java objects, just like we do while reading JSON String in Java.įor a long time, I was like a DIY guy, I mean, I would like to code everything I need and that's why I always have that big Utility class in my every Java project but things changed after reading Effective Java. It's also highly configurable and allows you to define a columns separator to read a text file with any delimiter. You can even read a tab-delimited text file like CSV. For example, you can read a CSV file with a header or without a header. The Jackson DataFormat CSV library allows you to read a CSV file in just a couple of lines and it's really powerful and feature-rich. For a long time, I only knew that Jackson can be used to parse JSON but later realized that you can also use it to parse or read CSV files in Java. Hello guys, today I am going to show you how to read a CSV file in Java with a simple example of Jackson API.
0 Comments
Leave a Reply. |