|
UserGuide
InstallationInstallation depends on what build mechanism you are using. Below are instructions for Ant and Maven. Ant
Maven
<dependency> <groupId>com.brsanthu</groupId> <artifactId>data-exporter</artifactId> <version>1.0.0</version> </dependency> 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 UsageUber Basic ExampleLet'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());
|