views:

112

answers:

1

In a lot of real life implementations of applications we face the requirement to import some kind of (text) files. Usually we would implement some (hardcoded?) logic to validate the file (eg. proper header, proper number of delimiters, proper date/time value,etc.). Eventually also need to check for the existence of related data in a table (eg. value of field 1 in text file must have an entry in some basic data table).

While XML solves this (to some extend) with XSD and DTD, we end up hacking this again and again for proprietary text file formats.

Is there any library or framework that allows the creation of templates similar to the xsd approach ? This would make it way more flexible to react on file format changes or implement new formats.

Thanks for any hints

Sven

+1  A: 

Closest thing I can think of is FileHelpers. It's in C#, so it would have to be ported to Java, but that shouldn't be a big deal.

Robert Harvey
There is a little java library for CSV crunching. SuperCSV http://supercsv.sourceforge.net/index.html
devdude
and openCSV http://opencsv.sourceforge.net/
devdude
another optin is the Apache POI Project http://poi.apache.org
devdude