Categories
Applications CSV

CSV Utility Package V1.0.1 released

A new update of my CSV Utility Package was released. It contains some fixes and enhancements:

  • Build system creates tar archive
  • Fixed Bug #2: NullPointerException in CSVReader class
  • Fixed Bug #4: Multiline values fail when a line looks like a comment
  • Enhancement #7: Excel Fix: first column of first row must not start with “ID”
  • Enhancement #8: Add row and column count

You can download the latest release here.

Categories
Java Templating

Templating Java Package 1.0.1 released

A new minor release of Templating Java Package has just been released. It fixes a major bug when replacing markers with values that itself contain strings looking like regular expressions. All such expressions are masked now to prevent an exception.

Download the release here.

Categories
Java Templating

Templating Java Package

You might remember my Templating post describing a Java class that implements a Typo3-like technique for a templating machine. I made a Java package out of it and you can use it right away. Just download it here. The API documentation is available, too.

Categories
CSV Java

CSV Utility Package Released

I decided recently to publish my very simple utility classes for reading and writing CSV files. The main project page is now available. The package, published under the GNU Lesser General Public License, allows you to easily integrate CSV functionality into your application. The utilities can be configured to use different column delimiter and separator characters in case you need to adopt some other versions of CSV. The default configuration conforms to the Excel style of CSV.

Since this CSV package uses streams, you are able to read from any stream. And, of course, you can write to any stream. You could even synchronize in your application by applying the reader/writer synchronization described in one of my artices.

You can download the latest stable release at the main project page.

Here is a short example on reading a CSV file using the CSVReader class:

java.io.File f = new java.io.File("csv-test.csv");
csv.CSVReader in = new csv.CSVReader(new java.io.FileReader(f));
while (in.hasNext()) {
    String columns[] = in.next();
    // Do something here
}
in.close();

Please note that the CSVReader class actually implements the Iterator interface.

Writing a CSV file is even easier. Just create an instance of the CSVWriter class and pass it your rows:

java.io.File f = new java.io.File("csv-test.csv");
CSVWriter out = new CSVWriter(new java.io.FileWriter(f));
out.printRow(new String[] { "0:0", "0:1", "0:2" });
out.printRow(new String[] { "1:0", "1:1", "1:2" });
out.close();

Documentation

The API documentation tells you all details and configuration parameters that you can use to control the behaviour of the reader and writer classes.