My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
UserGuide  

Installation

Installation depends on what build mechanism you are using. Below are instructions for Ant and Maven.

Ant

  • Download the jar file, add to your project library.
  • Alternatively, you can also download the jar file with its dependencies so you can unzip all jars required to run the basic example into your project library.

Maven

  • Add the following dependency statement to your pom file.
  •   	<dependency>
      		<groupId>com.brsanthu</groupId>
      		<artifactId>data-exporter</artifactId>
      		<version>1.0.0</version>
      	</dependency>
  • As the jar files are not replicated to Maven Central yet, you would need to install the jar file locally or into your enterprise repository. Simple is to install to your local repository using following command.
mvn install:install-file -DgroupId=com.brsanthu -DartifactId=data-exporter -Dversion=1.0.0 -Dpackaging=jar -Dfile=http://data-exporter.googlecode.com/files/data-exporter-1.0.0.jar

Usage

Uber Basic Example

Let's start with very basic example of printing the "Hello World!" using data exporter. Copy and paste following code to your Java IDE and run it.

package com.brsanthu.dataexporter.examples;

import com.brsanthu.dataexporter.DataExporter;
import com.brsanthu.dataexporter.output.text.TextExporter;

public class DataExporterHelloWorld {
    
    public static void main(String[] args) {
        DataExporter exporter = new TextExporter();
        exporter.addColumn("Hello");
        exporter.addRow("World!");
        exporter.finishExporting();
    }
}

This must print as follows.

Hello
World!

In the above example DataExporter is a main API base class which all other specific formatting exporters (like Text, Csv etc) would extend, in this case TextExporter.

DataExporter let's you set export options, add columns, add rows and finish exporting.

Depending on the exporter you have specified and options you have set, output content/format would vary.

By default DataExporter would output to System.out but that can be easily changed by specifying your own OutputStream or Writer as follows.

        StringWriter sw = new StringWriter();
        
        DataExporter exporter = new TextExporter(sw);
        exporter.addColumn("Hello");
        exporter.addRow("World!");
        exporter.finishExporting();
        
        System.out.println(sw.toString());

Sign in to add a comment
Powered by Google Project Hosting