APIdia Launch Partner
Top Description Inners Fields Constructors Methods
io.github.spannm.jackcess.util

public final Class ExportUtil

extends Object
Class Inheritance
Imports
io.github.spannm.jackcess.Column, .Cursor, .CursorBuilder, .Database, .Row, io.github.spannm.jackcess.impl.ByteUtil, java.io.BufferedWriter, .File, .FileOutputStream, .IOException, .OutputStreamWriter, java.nio.charset.Charset, java.util.ArrayList, .Collection, .HashSet, .Iterator, .List, java.util.regex.Pattern

Utility class for exporting tables from an Access database to other formats. See the Builder for convenient configuration of the export functionality. Note that most scenarios for customizing output data can be handled by implementing a custom ExportFilter.
Author
Frank Gerbig

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
ExportUtil.Builder

Builder which simplifies configuration of an export operation.

Field Summary

Modifier and TypeField and Description
public static final String
public static final String
public static final char

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static void
exportAll(Database
Database the table to export belongs to
db
,
File
The directory where the new files will be created
dir
)

Copy all tables into new delimited text files Equivalent to: exportAll(db, dir, "csv");

public static void
exportAll(Database
Database the table to export belongs to
db
,
File
The directory where the new files will be created
dir
,
String
The file extension of the new files
ext
)

Copy all tables into new delimited text files Equivalent to: exportFile(db, name, f, false, null, '"', SimpleExportFilter.INSTANCE);

public static void
exportAll(Database
Database the table to export belongs to
db
,
File
The directory where the new files will be created
dir
,
String
The file extension of the new files
ext
,
boolean
If true the first line contains the column names
header
)

Copy all tables into new delimited text files Equivalent to: exportFile(db, name, f, false, null, '"', SimpleExportFilter.INSTANCE);

public static void
exportAll(Database
Database the table to export belongs to
db
,
File
The directory where the new files will be created
dir
,
String
The file extension of the new files
ext
,
boolean
If true the first line contains the column names
header
,
String
The column delimiter, null for default (comma)
delim
,
char
The quote character
quote
,
ExportFilter
valid export filter
filter
)

Copy all tables into new delimited text files Equivalent to: exportFile(db, name, f, false, null, '"', SimpleExportFilter.INSTANCE);

public static void
exportFile(Database
Database the table to export belongs to
db
,
String
Name of the table to export
tableName
,
File
New file to create
f
)

Copy a table into a new delimited text file Equivalent to: exportFile(db, name, f, false, null, '"', SimpleExportFilter.INSTANCE);

public static void
exportFile(Database
Database the table to export belongs to
db
,
String
Name of the table to export
tableName
,
File
New file to create
f
,
boolean
If true the first line contains the column names
header
,
String
The column delimiter, null for default (comma)
delim
,
char
The quote character
quote
,
ExportFilter
valid export filter
filter
)

Copy a table into a new delimited text file Nearly equivalent to: exportWriter(db, name, new BufferedWriter(f), header, delim, quote, filter);

public static void
exportWriter(Database
Database the table to export belongs to
db
,
String
Name of the table to export
tableName
,
BufferedWriter
Writer to export to
out
)

Copy a table in this database into a new delimited text file Equivalent to: exportWriter(db, name, out, false, null, '"', SimpleExportFilter.INSTANCE);

public static void
exportWriter(Database
Database the table to export belongs to
db
,
String
Name of the table to export
tableName
,
BufferedWriter
Writer to export to
out
,
boolean
If true the first line contains the column names
header
,
String
The column delimiter, null for default (comma)
delim
,
char
The quote character
quote
,
ExportFilter
valid export filter
filter
)

Copy a table in this database into a new delimited text file.

public static void
exportWriter(Cursor
Cursor to export
cursor
,
BufferedWriter
Writer to export to
out
,
boolean
If true the first line contains the column names
header
,
String
The column delimiter, null for default (comma)
delim
,
char
The quote character
quote
,
ExportFilter
valid export filter
filter
)

Copy a table in this database into a new delimited text file.

private static void
writeValue(BufferedWriter out, String value, char quote, Pattern needsQuotePattern)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULT_DELIMITERback to summary
public static final String DEFAULT_DELIMITER
DEFAULT_FILE_EXTback to summary
public static final String DEFAULT_FILE_EXT
DEFAULT_QUOTE_CHARback to summary
public static final char DEFAULT_QUOTE_CHAR

Constructor Detail

ExportUtilback to summary
private ExportUtil()

Method Detail

exportAllback to summary
public static void exportAll(Database db, File dir) throws IOException

Copy all tables into new delimited text files
Equivalent to: exportAll(db, dir, "csv");

Parameters
db:Database

Database the table to export belongs to

dir:File

The directory where the new files will be created

See Also
exportAll(Database, File, String), Builder
exportAllback to summary
public static void exportAll(Database db, File dir, String ext) throws IOException

Copy all tables into new delimited text files
Equivalent to: exportFile(db, name, f, false, null, '"', SimpleExportFilter.INSTANCE);

Parameters
db:Database

Database the table to export belongs to

dir:File

The directory where the new files will be created

ext:String

The file extension of the new files

See Also
exportFile(Database, String, File, boolean, String, char, ExportFilter), Builder
exportAllback to summary
public static void exportAll(Database db, File dir, String ext, boolean header) throws IOException

Copy all tables into new delimited text files
Equivalent to: exportFile(db, name, f, false, null, '"', SimpleExportFilter.INSTANCE);

Parameters
db:Database

Database the table to export belongs to

dir:File

The directory where the new files will be created

ext:String

The file extension of the new files

header:boolean

If true the first line contains the column names

See Also
exportFile(Database, String, File, boolean, String, char, ExportFilter), Builder
exportAllback to summary
public static void exportAll(Database db, File dir, String ext, boolean header, String delim, char quote, ExportFilter filter) throws IOException

Copy all tables into new delimited text files
Equivalent to: exportFile(db, name, f, false, null, '"', SimpleExportFilter.INSTANCE);

Parameters
db:Database

Database the table to export belongs to

dir:File

The directory where the new files will be created

ext:String

The file extension of the new files

header:boolean

If true the first line contains the column names

delim:String

The column delimiter, null for default (comma)

quote:char

The quote character

filter:ExportFilter

valid export filter

See Also
exportFile(Database, String, File, boolean, String, char, ExportFilter), Builder
exportFileback to summary
public static void exportFile(Database db, String tableName, File f) throws IOException

Copy a table into a new delimited text file
Equivalent to: exportFile(db, name, f, false, null, '"', SimpleExportFilter.INSTANCE);

Parameters
db:Database

Database the table to export belongs to

tableName:String

Name of the table to export

f:File

New file to create

See Also
exportFile(Database, String, File, boolean, String, char, ExportFilter), Builder
exportFileback to summary
public static void exportFile(Database db, String tableName, File f, boolean header, String delim, char quote, ExportFilter filter) throws IOException

Copy a table into a new delimited text file
Nearly equivalent to: exportWriter(db, name, new BufferedWriter(f), header, delim, quote, filter);

Parameters
db:Database

Database the table to export belongs to

tableName:String

Name of the table to export

f:File

New file to create

header:boolean

If true the first line contains the column names

delim:String

The column delimiter, null for default (comma)

quote:char

The quote character

filter:ExportFilter

valid export filter

See Also
exportWriter(Database, String, BufferedWriter, boolean, String, char, ExportFilter), Builder
exportWriterback to summary
public static void exportWriter(Database db, String tableName, BufferedWriter out) throws IOException

Copy a table in this database into a new delimited text file
Equivalent to: exportWriter(db, name, out, false, null, '"', SimpleExportFilter.INSTANCE);

Parameters
db:Database

Database the table to export belongs to

tableName:String

Name of the table to export

out:BufferedWriter

Writer to export to

See Also
exportWriter(Database, String, BufferedWriter, boolean, String, char, ExportFilter), Builder
exportWriterback to summary
public static void exportWriter(Database db, String tableName, BufferedWriter out, boolean header, String delim, char quote, ExportFilter filter) throws IOException

Copy a table in this database into a new delimited text file.
Equivalent to: exportWriter(Cursor.createCursor(db.getTable(tableName)), out, header, delim, quote, filter);

Parameters
db:Database

Database the table to export belongs to

tableName:String

Name of the table to export

out:BufferedWriter

Writer to export to

header:boolean

If true the first line contains the column names

delim:String

The column delimiter, null for default (comma)

quote:char

The quote character

filter:ExportFilter

valid export filter

See Also
exportWriter(Cursor, BufferedWriter, boolean, String, char, ExportFilter), Builder
exportWriterback to summary
public static void exportWriter(Cursor cursor, BufferedWriter out, boolean header, String delim, char quote, ExportFilter filter) throws IOException

Copy a table in this database into a new delimited text file.

Parameters
cursor:Cursor

Cursor to export

out:BufferedWriter

Writer to export to

header:boolean

If true the first line contains the column names

delim:String

The column delimiter, null for default (comma)

quote:char

The quote character

filter:ExportFilter

valid export filter

See Also
Builder
writeValueback to summary
private static void writeValue(BufferedWriter out, String value, char quote, Pattern needsQuotePattern) throws IOException
io.github.spannm.jackcess.util back to summary

public Class ExportUtil.Builder

extends Object
Class Inheritance

Builder which simplifies configuration of an export operation.

Field Summary

Modifier and TypeField and Description
private Cursor
private Database
private String
private String
private ExportFilter
private boolean
private char
private String

Constructor Summary

AccessConstructor and Description
public
public
Builder(Database _db, String _tableName)

public
Builder(Cursor _cursor)

Method Summary

Modifier and TypeMethod and Description
public void
exportAll(File dir)

Exports all tables of the database to the given directory, using the settings of this builder.

public void
exportFile(File f)

Exports the table to the given file, using the settings of this builder.

public void
exportWriter(BufferedWriter writer)

Exports the table or cursor to the given writer, using the settings of this builder.

public ExportUtil.Builder
withCursor(Cursor _cursor)

public ExportUtil.Builder
public ExportUtil.Builder
public ExportUtil.Builder
public ExportUtil.Builder
public ExportUtil.Builder
withHeader(boolean _header)

public ExportUtil.Builder
withQuote(char _quote)

public ExportUtil.Builder
withTableName(String _tableName)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

mcursorback to summary
private Cursor mcursor
mdbback to summary
private Database mdb
mdelimback to summary
private String mdelim
mextback to summary
private String mext
mfilterback to summary
private ExportFilter mfilter
mheaderback to summary
private boolean mheader
mquoteback to summary
private char mquote
mtableNameback to summary
private String mtableName

Constructor Detail

Builderback to summary
public Builder(Database _db)
Builderback to summary
public Builder(Database _db, String _tableName)
Builderback to summary
public Builder(Cursor _cursor)

Method Detail

exportAllback to summary
public void exportAll(File dir) throws IOException

Exports all tables of the database to the given directory, using the settings of this builder.

See Also
ExportUtil#exportAll(Database, File, String, boolean, String, char, ExportFilter)
exportFileback to summary
public void exportFile(File f) throws IOException

Exports the table to the given file, using the settings of this builder.

See Also
ExportUtil#exportFile(Database, String, File, boolean, String, char, ExportFilter)
exportWriterback to summary
public void exportWriter(BufferedWriter writer) throws IOException

Exports the table or cursor to the given writer, using the settings of this builder.

See Also
ExportUtil#exportWriter(Database, String, BufferedWriter, boolean, String, char, ExportFilter), ExportUtil#exportWriter(Cursor, BufferedWriter, boolean, String, char, ExportFilter)
withCursorback to summary
public ExportUtil.Builder withCursor(Cursor _cursor)
withDatabaseback to summary
public ExportUtil.Builder withDatabase(Database _db)
withDelimiterback to summary
public ExportUtil.Builder withDelimiter(String _delim)
withFileNameExtensionback to summary
public ExportUtil.Builder withFileNameExtension(String _ext)
withFilterback to summary
public ExportUtil.Builder withFilter(ExportFilter _filter)
withHeaderback to summary
public ExportUtil.Builder withHeader(boolean _header)
withQuoteback to summary
public ExportUtil.Builder withQuote(char _quote)
withTableNameback to summary
public ExportUtil.Builder withTableName(String _tableName)