Sign in

E-mail *, (xx@domain.com)
Password *

Register | Forgot password

Blogs

Recent blogs

RSS - Blogs
March 9, 2010
State of OSGi in the Java world
March 4, 2010
Reach more people with Google Translate
March 3, 2010
Get My Advice
February 26, 2010
What? Where!?!
February 11, 2010
Split it!

All Blogs...


Short story about not inventing another wheel

March 21, 2008

One of the aspects of my job is to write Java code. It’s a nice task and I like it, but I’m not addicted to it. So once in a while I don’t want to write Java code, because I think at this planet there must be at least one person that already wrote what I need and that decided to share the code. With MaVeN I can easily include a Java library written by a third party, so in 15 minutes I can parse all kinds of CSV files.

Finding the library I need

Last week I described how to stream a file from the browser to WebManager. This file happened to be a CSV file and I need to do some processing for each entry in the file. Some CSV files are simple and each line has a set of fields separated by some special character. But in my CSV file this character can occur as content in the fields, so I needed to parse escaping and I had to cope with newlines inside fields. My bet was that someone needed this before, so I opened up my browser and found OpenCSV. The library is distributed using the Apache 2.0 license, so I am allowed to use and distribute it as part of my WCB.

Adding the lib to my project

After I checked for documentation, known bugs and some more about the project, I decided to use it for my WCB. A search on mvnrepository gave me the following POM dependency:

<dependency>
    <groupId>net.sf.opencsv</groupId>
    <artifactId>opencsv</artifactId>
    <version>1.8</version>
</dependency>

All I do is copy these lines, open up Eclipse, paste them into my projects pom.xml, save the file and the MaVeN plugin automatically downloads the library from the central repository and adds it to the projects classpath. Using the API documentation of the library I finished my WCB the same day.



About the Author

Return to all blogs


Mark is software engineer with a special interest in Security and Digital WebTV. Mark writes about daily engineering with GX WebManager

Read all Marks blog entries

Other blog entries:

March 3, 2010
Get My Advice
February 11, 2010
Split it!
April 22, 2009
What goes in, must come out!
July 29, 2008
WCB Sharing FTW!
June 17, 2008
Found me on LinkedIn?
April 18, 2008
Tosti
April 7, 2008
Baking apple pie at 347
March 13, 2008
Files in and files out
February 29, 2008
Big Brother is watching


Share:

del.icio.us
digg
Technorati
Slashdot
Reddit
YahooMyWeb
NewsVine
ekudos
© 2010 GX creative online development B.V.

Disclaimer

This website (GXdeveloperweb.com) may discuss or contain opinions, (sample) coding, software or other information that does not include GX official interfaces, instructions or guidelines and therefore is not supported by GX. Changes made based on this information are not supported.  GX will not be held liable for any damages caused by using or misusing the information, software, instructions, code or methods suggested on this website, and anyone using these methods does so at his/her own risk. GX offers no guarantees and assumes no responsibility or liability of any type with respect to the content of this website, including any liability resulting from incompatibility between the content of this website and the materials and services offered by GX. By using this website you will not hold, or seek to hold, GX responsible or liable with respect to the content of this website.