本文整理匯總了Java中com.opencsv.CSVWriter.DEFAULT_SEPARATOR屬性的典型用法代碼示例。如果您正苦於以下問題:Java CSVWriter.DEFAULT_SEPARATOR屬性的具體用法?Java CSVWriter.DEFAULT_SEPARATOR怎麽用?Java CSVWriter.DEFAULT_SEPARATOR使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類com.opencsv.CSVWriter
的用法示例。
在下文中一共展示了CSVWriter.DEFAULT_SEPARATOR屬性的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initialise
@Override
public void initialise() throws IOException {
// Create the parent dirs
new File(csvFilename).getAbsoluteFile().getParentFile().mkdirs();
writer = new CSVWriter(new FileWriter(csvFilename, false), CSVWriter.DEFAULT_SEPARATOR, CSVWriter.NO_QUOTE_CHARACTER);
// Print the header
writer.writeNext(new String[] {
"Type",
"Subtype",
"Source type",
"Target type",
"Lemma",
"Lemma POS",
"Alternatives...."
});
}
示例2: detectSeparator
public static char detectSeparator(String line) {
StringBuffer buffer = new StringBuffer();
Matcher matcher = UNIVERSAL_ALIAS_PATTERN.matcher(line);
while (matcher.find()) {
matcher.appendReplacement(buffer, "");
}
matcher.appendTail(buffer);
String separateDetection = buffer.toString().replaceAll("[^,;|\\t]*", "");
if (separateDetection == null)
throw new ReportFormattingException("Error while detecting a separator");
if (!separateDetection.isEmpty())
return separateDetection.charAt(0);
else
return CSVWriter.DEFAULT_SEPARATOR;
}
示例3: save
/**
* <p>Saves the table values to the given file.</p>
* @param file
* @throws IOException
*/
public void save(File file) throws IOException {
CSVWriter writer = new CSVWriter(new FileWriter(file, true), CSVWriter.DEFAULT_SEPARATOR, CSVWriter.NO_QUOTE_CHARACTER);
int rowCount = model.getRowCount();
int columnCount = model.getColumnCount();
for(int i = 0; i < rowCount; i++) {
String[] row = new String[columnCount];
for(int a = 0; a < columnCount; a++) {
row[a] = String.valueOf(model.getValueAt(i, a));
}
writer.writeNext(row);
}
writer.close();
}
示例4: runTask
private boolean runTask() {
if (mAdapter == null || mAdapter.getCursor() == null)
return false;
// take cursor
Cursor data = mAdapter.getCursor();
// create object to write csv file
try {
CSVWriter csvWriter = new CSVWriter(new FileWriter(mFileName), CSVWriter.DEFAULT_SEPARATOR,
CSVWriter.NO_QUOTE_CHARACTER);
while (data.moveToNext()) {
String[] record = new String[7];
// compose a records
record[0] = data.getString(data.getColumnIndex(QueryAllData.UserDate));
if (!TextUtils.isEmpty(data.getString(data.getColumnIndex(QueryAllData.Payee)))) {
record[1] = data.getString(data.getColumnIndex(QueryAllData.Payee));
} else {
record[1] = data.getString(data.getColumnIndex(QueryAllData.AccountName));
}
record[2] = Double.toString(data.getDouble(data.getColumnIndex(QueryAllData.Amount)));
record[3] = data.getString(data.getColumnIndex(QueryAllData.Category));
record[4] = data.getString(data.getColumnIndex(QueryAllData.Subcategory));
record[5] = Integer.toString(data.getInt(data.getColumnIndex(QueryAllData.TransactionNumber)));
record[6] = data.getString(data.getColumnIndex(QueryAllData.Notes));
// writer record
csvWriter.writeNext(record);
// move to next row
data.moveToNext();
}
csvWriter.close();
} catch (Exception e) {
Timber.e(e, "exporting to CSV");
return false;
}
return true;
}
示例5: export
static int export(Database db, String tableName, Writer csv, boolean withHeader, boolean applyQuotesToAll, String nullText) throws IOException{
Table table = db.getTable(tableName);
String[] buffer = new String[table.getColumnCount()];
CSVWriter writer = new CSVWriter(new BufferedWriter(csv), CSVWriter.DEFAULT_SEPARATOR, CSVWriter.DEFAULT_QUOTE_CHARACTER);
int rows = 0;
try{
if (withHeader) {
int x = 0;
for(Column col : table.getColumns()){
buffer[x++] = col.getName();
}
writer.writeNext(buffer, applyQuotesToAll);
}
for(Row row : table){
int i = 0;
for (Object object : row.values()) {
buffer[i++] = object == null ? nullText : object.toString();
}
writer.writeNext(buffer, applyQuotesToAll);
rows++;
}
}finally{
writer.close();
}
return rows;
}