reading data from a text file in J2EE application
Posted on 2006-07-03
I am working in a J2ee application using Spring MVC framework and Hibernate with websphere application server. I am trying to develop a upload module where user can select a tab delimited text file from his machine and upload data from it into oracle 10g database (our backend). So the user should select the file, the file-type (a drop down menu) and click upload and the data should be in the database. The tab-delimited text file is nothing but excel spreadsheet tables (with first row as header). I have matching columns in the database for each column in the text file. (Note: I have seen the Apache POI framework but want to avoid it, as some of files are coming as text and some as .xsl, so I am converting everything into .txt).
Is there anything in Spring framework that will help me in this. Or else, I am thinking of using simple java IO and use regular expression to extract the data and pump it into hibernate to save it in persistant storage. The other option is perl, but how do I invoke a perl script in websphere app server. A small sample routine will be very helpful whatever the best way to do this.....
You can assume that my text file looks like this:
ColHdr1 ColdHdr2 ColHdr3 ColHdr4 -----> column header
qwe bbbbb qqwjxjx bhjuytg ------> row #1 data
dgt aghui kjiu kiyrcd ........
qwsju kiuyt juht juyt ........