JTextFileParser is a java package built for simplifing delimited text files parsing. It gives you a quick way for parsing a delimited text file, managing rows and fields.
To use this package you need JDK 1.3 or greater.
This project his hosted on Google Code
Download
JTextFileParser 1.3
Zip archive containing source code, binary files and documentation (132Kb).
JTextFileParser is open source and is released under GNU General Public License v3
Quick start
Parsing a delimited text file with JTextFileParser is easy and starightforward: you only need to instantiate a TextFile object specifing the fille name, the file path and field’s separator.
TextFile file = new TextFile("file.txt","C:\\Temp","\t");
When you instantiate the TextFile object, the text file is parsed so you can easily access every row and every row’s field.
Now you can:
- Get a specified row as a String
- Get a specified row as a Row object
- Get all rows as an ArrayList? of Row objects
- Check the number of rows into the text file
- Check if every row has the same number of fields
- Check if every row has the specified number of fields
- Create a copy of the file
- Create a copy of the file with a different fields separator
- Create a text file with a subset of rows from the original file
- Create a text file with a subset of rows from the original file with a different fields separator
- Create a text file with a subset of rows and a subset of fields from the original file
- Create a text file with a subset of rows and a subset of fields from the original file with a different fields separator
- Export data to an HTML file
Check out the javadoc for more info.
Version history
1.3 - 06.12.2008
- Added the option to build a TextFile object from an ArrayList of Row objects
- Rewritten the code for accessing files: added the FileManager class
- Improved the HTML export function: now you’ll get nicely formatted tables and valid XHTML markup. You can also specify your custom stylesheet.
- Code optimization and cleanup
1.2 - 03.12.2008
- Added the option to ignore the first line of the file.
Now you can create a TextFile object specifing thehasHeaderparameter (true|false). If you sethasHeaderto true you’ll be able to access the header row using the methodgetHeaderRow()and the first row returned by the methodgetRows()will be the second row of the file. - Added the method
replaceRows(ArrayList rows)in the TextFile class. This method will replace all rows in the TextFile? object - Deprecated the method
getSimpleRowin the Row class. From now on you should use the methodgetStringRow
1.1 - 01.26.2008
- Added a method to export the text file to an HTML page
- Added a method to export selected rows to an HTML page
- Added a method to export selected rows and selected fields to an HTML page
- Some code cleanup
1.0 - 01.26.2008
First public release
Disclaimer
Please remember: “This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.“
