public class ExportUtil extends 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 String |
DEFAULT_DELIMITER |
static String |
DEFAULT_FILE_EXT |
static char |
DEFAULT_QUOTE_CHAR |
Modifier and Type | Method and Description |
---|---|
static void |
exportAll(Database db,
File dir)
Copy all tables into new delimited text files
Equivalent to: exportAll(db, dir, "csv"); |
static void |
exportAll(Database db,
File dir,
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,
File dir,
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,
File dir,
String ext,
boolean header,
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,
String tableName,
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,
String tableName,
File f,
boolean header,
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,
BufferedWriter out,
boolean header,
String delim,
char quote,
ExportFilter filter)
Copy a table in this database into a new delimited text file.
|
static void |
exportWriter(Database db,
String tableName,
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,
String tableName,
BufferedWriter out,
boolean header,
String delim,
char quote,
ExportFilter filter)
Copy a table in this database into a new delimited text file.
|
public static final String DEFAULT_DELIMITER
public static final char DEFAULT_QUOTE_CHAR
public static final String DEFAULT_FILE_EXT
public static void exportAll(Database db, File dir) throws IOException
exportAll(db, dir, "csv");
db
- Database the table to export belongs todir
- The directory where the new files will be createdIOException
exportAll(Database,File,String)
,
ExportUtil.Builder
public static void exportAll(Database db, File dir, String ext) throws 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 filesIOException
exportFile(Database,String,File,boolean,String,char,ExportFilter)
,
ExportUtil.Builder
public static void exportAll(Database db, File dir, String ext, boolean header) throws 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 namesIOException
exportFile(Database,String,File,boolean,String,char,ExportFilter)
,
ExportUtil.Builder
public static void exportAll(Database db, File dir, String ext, boolean header, String delim, char quote, ExportFilter filter) throws 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 filterIOException
exportFile(Database,String,File,boolean,String,char,ExportFilter)
,
ExportUtil.Builder
public static void exportFile(Database db, String tableName, File f) throws 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 createIOException
exportFile(Database,String,File,boolean,String,char,ExportFilter)
,
ExportUtil.Builder
public static void exportFile(Database db, String tableName, File f, boolean header, String delim, char quote, ExportFilter filter) throws 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 filterIOException
exportWriter(Database,String,BufferedWriter,boolean,String,char,ExportFilter)
,
ExportUtil.Builder
public static void exportWriter(Database db, String tableName, BufferedWriter out) throws 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 toIOException
exportWriter(Database,String,BufferedWriter,boolean,String,char,ExportFilter)
,
ExportUtil.Builder
public static void exportWriter(Database db, String tableName, BufferedWriter out, boolean header, String delim, char quote, ExportFilter filter) throws 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 filterIOException
exportWriter(Cursor,BufferedWriter,boolean,String,char,ExportFilter)
,
ExportUtil.Builder
public static void exportWriter(Cursor cursor, BufferedWriter out, boolean header, String delim, char quote, ExportFilter filter) throws 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 filterIOException
ExportUtil.Builder
Copyright © 2005–2024 OpenHMS. All rights reserved.