Class ExportUtil
- java.lang.Object
-
- com.healthmarketscience.jackcess.util.ExportUtil
-
public class ExportUtil extends Object
Utility class for exporting tables from an Access database to other formats. See theExportUtil.Builderfor convenient configuration of the export functionality. Note that most scenarios for customizing output data can be handled by implementing a customExportFilter.- Author:
- Frank Gerbig
- Usage:
- General: This class is general use.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classExportUtil.BuilderBuilder which simplifies configuration of an export operation.
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_DELIMITERstatic StringDEFAULT_FILE_EXTstatic charDEFAULT_QUOTE_CHAR
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidexportAll(Database db, File dir)Copy all tables into new delimited text files
Equivalent to:exportAll(db, dir, "csv");static voidexportAll(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 voidexportAll(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 voidexportAll(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 voidexportFile(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 voidexportFile(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 voidexportWriter(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 voidexportWriter(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 voidexportWriter(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.
-
-
-
Field Detail
-
DEFAULT_DELIMITER
public static final String DEFAULT_DELIMITER
- See Also:
- Constant Field Values
-
DEFAULT_QUOTE_CHAR
public static final char DEFAULT_QUOTE_CHAR
- See Also:
- Constant Field Values
-
DEFAULT_FILE_EXT
public static final String DEFAULT_FILE_EXT
- See Also:
- Constant Field Values
-
-
Method Detail
-
exportAll
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 the table to export belongs todir- The directory where the new files will be created- Throws:
IOException- See Also:
exportAll(Database,File,String),ExportUtil.Builder
-
exportAll
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 the table to export belongs todir- The directory where the new files will be createdext- The file extension of the new files- Throws:
IOException- See Also:
exportFile(Database,String,File,boolean,String,char,ExportFilter),ExportUtil.Builder
-
exportAll
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 the table to export belongs todir- The directory where the new files will be createdext- The file extension of the new filesheader- Iftruethe first line contains the column names- Throws:
IOException- See Also:
exportFile(Database,String,File,boolean,String,char,ExportFilter),ExportUtil.Builder
-
exportAll
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 the table to export belongs todir- The directory where the new files will be createdext- The file extension of the new filesheader- Iftruethe first line contains the column namesdelim- The column delimiter,nullfor default (comma)quote- The quote characterfilter- valid export filter- Throws:
IOException- See Also:
exportFile(Database,String,File,boolean,String,char,ExportFilter),ExportUtil.Builder
-
exportFile
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 the table to export belongs totableName- Name of the table to exportf- New file to create- Throws:
IOException- See Also:
exportFile(Database,String,File,boolean,String,char,ExportFilter),ExportUtil.Builder
-
exportFile
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 the table to export belongs totableName- Name of the table to exportf- New file to createheader- Iftruethe first line contains the column namesdelim- The column delimiter,nullfor default (comma)quote- The quote characterfilter- valid export filter- Throws:
IOException- See Also:
exportWriter(Database,String,BufferedWriter,boolean,String,char,ExportFilter),ExportUtil.Builder
-
exportWriter
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 the table to export belongs totableName- Name of the table to exportout- Writer to export to- Throws:
IOException- See Also:
exportWriter(Database,String,BufferedWriter,boolean,String,char,ExportFilter),ExportUtil.Builder
-
exportWriter
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 the table to export belongs totableName- Name of the table to exportout- Writer to export toheader- Iftruethe first line contains the column namesdelim- The column delimiter,nullfor default (comma)quote- The quote characterfilter- valid export filter- Throws:
IOException- See Also:
exportWriter(Cursor,BufferedWriter,boolean,String,char,ExportFilter),ExportUtil.Builder
-
exportWriter
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 to exportout- Writer to export toheader- Iftruethe first line contains the column namesdelim- The column delimiter,nullfor default (comma)quote- The quote characterfilter- valid export filter- Throws:
IOException- See Also:
ExportUtil.Builder
-
-