public class ExportUtil
extends java.lang.Object
ExportUtil.Builder for convenient configuration of the
export functionality. Note that most scenarios for customizing output data
can be handled by implementing a custom ExportFilter.| Modifier and Type | Class and Description |
|---|---|
static class |
ExportUtil.Builder
Builder which simplifies configuration of an export operation.
|
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
DEFAULT_DELIMITER |
static java.lang.String |
DEFAULT_FILE_EXT |
static char |
DEFAULT_QUOTE_CHAR |
| Modifier | Constructor and Description |
|---|---|
private |
ExportUtil() |
| Modifier and Type | Method and Description |
|---|---|
static void |
exportAll(Database db,
java.io.File dir)
Copy all tables into new delimited text files
Equivalent to: exportAll(db, dir, "csv"); |
static void |
exportAll(Database db,
java.io.File dir,
java.lang.String ext)
Copy all tables into new delimited text files
Equivalent to: exportFile(db, name, f, false, null, '"',
SimpleExportFilter.INSTANCE); |
static void |
exportAll(Database db,
java.io.File dir,
java.lang.String ext,
boolean header)
Copy all tables into new delimited text files
Equivalent to: exportFile(db, name, f, false, null, '"',
SimpleExportFilter.INSTANCE); |
static void |
exportAll(Database db,
java.io.File dir,
java.lang.String ext,
boolean header,
java.lang.String delim,
char quote,
ExportFilter filter)
Copy all tables into new delimited text files
Equivalent to: exportFile(db, name, f, false, null, '"',
SimpleExportFilter.INSTANCE); |
static void |
exportFile(Database db,
java.lang.String tableName,
java.io.File f)
Copy a table into a new delimited text file
Equivalent to: exportFile(db, name, f, false, null, '"',
SimpleExportFilter.INSTANCE); |
static void |
exportFile(Database db,
java.lang.String tableName,
java.io.File f,
boolean header,
java.lang.String delim,
char quote,
ExportFilter filter)
Copy a table into a new delimited text file
Nearly equivalent to: exportWriter(db, name, new BufferedWriter(f),
header, delim, quote, filter); |
static void |
exportWriter(Cursor cursor,
java.io.BufferedWriter out,
boolean header,
java.lang.String delim,
char quote,
ExportFilter filter)
Copy a table in this database into a new delimited text file.
|
static void |
exportWriter(Database db,
java.lang.String tableName,
java.io.BufferedWriter out)
Copy a table in this database into a new delimited text file
Equivalent to: exportWriter(db, name, out, false, null, '"',
SimpleExportFilter.INSTANCE); |
static void |
exportWriter(Database db,
java.lang.String tableName,
java.io.BufferedWriter out,
boolean header,
java.lang.String delim,
char quote,
ExportFilter filter)
Copy a table in this database into a new delimited text file.
|
private static void |
writeValue(java.io.BufferedWriter out,
java.lang.String value,
char quote,
java.util.regex.Pattern needsQuotePattern) |
public static final java.lang.String DEFAULT_DELIMITER
public static final char DEFAULT_QUOTE_CHAR
public static final java.lang.String DEFAULT_FILE_EXT
public static void exportAll(Database db, java.io.File dir) throws java.io.IOException
exportAll(db, dir, "csv");db - Database the table to export belongs todir - The directory where the new files will be createdjava.io.IOExceptionexportAll(Database,File,String),
ExportUtil.Builderpublic static void exportAll(Database db, java.io.File dir, java.lang.String ext) throws java.io.IOException
exportFile(db, name, f, false, null, '"',
SimpleExportFilter.INSTANCE);db - Database the table to export belongs todir - The directory where the new files will be createdext - The file extension of the new filesjava.io.IOExceptionexportFile(Database,String,File,boolean,String,char,ExportFilter),
ExportUtil.Builderpublic static void exportAll(Database db, java.io.File dir, java.lang.String ext, boolean header) throws java.io.IOException
exportFile(db, name, f, false, null, '"',
SimpleExportFilter.INSTANCE);db - Database the table to export belongs todir - The directory where the new files will be createdext - The file extension of the new filesheader - If true the first line contains the column namesjava.io.IOExceptionexportFile(Database,String,File,boolean,String,char,ExportFilter),
ExportUtil.Builderpublic static void exportAll(Database db, java.io.File dir, java.lang.String ext, boolean header, java.lang.String delim, char quote, ExportFilter filter) throws java.io.IOException
exportFile(db, name, f, false, null, '"',
SimpleExportFilter.INSTANCE);db - Database the table to export belongs todir - The directory where the new files will be createdext - The file extension of the new filesheader - If true the first line contains the column namesdelim - The column delimiter, null for default (comma)quote - The quote characterfilter - valid export filterjava.io.IOExceptionexportFile(Database,String,File,boolean,String,char,ExportFilter),
ExportUtil.Builderpublic static void exportFile(Database db, java.lang.String tableName, java.io.File f) throws java.io.IOException
exportFile(db, name, f, false, null, '"',
SimpleExportFilter.INSTANCE);db - Database the table to export belongs totableName - Name of the table to exportf - New file to createjava.io.IOExceptionexportFile(Database,String,File,boolean,String,char,ExportFilter),
ExportUtil.Builderpublic static void exportFile(Database db, java.lang.String tableName, java.io.File f, boolean header, java.lang.String delim, char quote, ExportFilter filter) throws java.io.IOException
exportWriter(db, name, new BufferedWriter(f),
header, delim, quote, filter);db - Database the table to export belongs totableName - Name of the table to exportf - New file to createheader - If true the first line contains the column namesdelim - The column delimiter, null for default (comma)quote - The quote characterfilter - valid export filterjava.io.IOExceptionexportWriter(Database,String,BufferedWriter,boolean,String,char,ExportFilter),
ExportUtil.Builderpublic static void exportWriter(Database db, java.lang.String tableName, java.io.BufferedWriter out) throws java.io.IOException
exportWriter(db, name, out, false, null, '"',
SimpleExportFilter.INSTANCE);db - Database the table to export belongs totableName - Name of the table to exportout - Writer to export tojava.io.IOExceptionexportWriter(Database,String,BufferedWriter,boolean,String,char,ExportFilter),
ExportUtil.Builderpublic static void exportWriter(Database db, java.lang.String tableName, java.io.BufferedWriter out, boolean header, java.lang.String delim, char quote, ExportFilter filter) throws java.io.IOException
exportWriter(Cursor.createCursor(db.getTable(tableName)), out, header, delim, quote, filter);db - Database the table to export belongs totableName - Name of the table to exportout - Writer to export toheader - If true the first line contains the column namesdelim - The column delimiter, null for default (comma)quote - The quote characterfilter - valid export filterjava.io.IOExceptionexportWriter(Cursor,BufferedWriter,boolean,String,char,ExportFilter),
ExportUtil.Builderpublic static void exportWriter(Cursor cursor, java.io.BufferedWriter out, boolean header, java.lang.String delim, char quote, ExportFilter filter) throws java.io.IOException
cursor - Cursor to exportout - Writer to export toheader - If true the first line contains the column namesdelim - The column delimiter, null for default (comma)quote - The quote characterfilter - valid export filterjava.io.IOExceptionExportUtil.Builderprivate static void writeValue(java.io.BufferedWriter out,
java.lang.String value,
char quote,
java.util.regex.Pattern needsQuotePattern)
throws java.io.IOException
java.io.IOException