本文整理匯總了Java中au.com.bytecode.opencsv.CSVWriter.flush方法的典型用法代碼示例。如果您正苦於以下問題:Java CSVWriter.flush方法的具體用法?Java CSVWriter.flush怎麽用?Java CSVWriter.flush使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類au.com.bytecode.opencsv.CSVWriter
的用法示例。
在下文中一共展示了CSVWriter.flush方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: exportCsv
import au.com.bytecode.opencsv.CSVWriter; //導入方法依賴的package包/類
public static void exportCsv(SortedMap<Number, Number> data, String filePath) {
try {
writer = new CSVWriter(new FileWriter(filePath), ',', '\0');
List<String[]> entries = new ArrayList<>(data.size());
for (Number x : data.keySet()) {
String xString = String.valueOf(x);
String yString = String.valueOf(data.get(x));
entries.add(new String[] { xString, yString });
}
writer.writeAll(entries);
writer.flush();
writer.close();
} catch (IOException e) {
System.err.println(e.getMessage());
}
}
示例2: getCustomerExportEmails
import au.com.bytecode.opencsv.CSVWriter; //導入方法依賴的package包/類
@GET
@Path("export/emails")
// @Produces("text/plain")
public Response getCustomerExportEmails(@FilterParam Filter filter, @Context HttpServletResponse response)
throws IOException {
response.setContentType("text/csv");
response.setHeader("Content-Disposition", "attachment; filename=\"customer-emails.csv\"");
PrintWriter printWriter = response.getWriter();
CSVWriter writer = new CSVWriter(printWriter, ';');
writer.writeNext(new String[] { "E-mail" });
List<Customer> customers = service.get(Customer.class);
for (Customer customer : customers) {
if (customer.getEmail() != null && !customer.getEmail().isEmpty()) {
writer.writeNext(new String[] { customer.getEmail() });
}
}
writer.flush();
writer.close();
return Response.ok().build();
}
示例3: printStatsAsCsvLine
import au.com.bytecode.opencsv.CSVWriter; //導入方法依賴的package包/類
/**
* Print config and stats as a CSV line.
*/
public void printStatsAsCsvLine(CSVWriter writer, String id,
Instances dataset, ExtendedEvaluation eval) {
int n = dataset.numInstances();
double p = eval.microAveragedPrecision();
double r = eval.microAveragedRecall();
double macroF1 = eval.macroAveragedFMeasure(1);
double microF1 = eval.microAveragedFMeasure(1);
double a = eval.accuracy();
String[] line = { id, String.valueOf(n), String.valueOf(a), String.valueOf(p),
String.valueOf(r), String.valueOf(macroF1), String.valueOf(microF1),
};
writer.writeNext(line);
try {
writer.flush();
} catch (IOException e) {
e.printStackTrace();
}
}
示例4: performFinish
import au.com.bytecode.opencsv.CSVWriter; //導入方法依賴的package包/類
@Override
public boolean performFinish() {
try {
CSVWriter writer = new CSVWriter(new FileWriter(new File(FileHandler.getCFGFilePath("regex.csv"))), ';');
writer.writeNext(new String[] {"Name","Regex"});
for (Regex r : CombineNodesCommand.getRegex()) {
if (!r.getName().isEmpty())
writer.writeNext(new String[] {r.getName(),r.getRegex().replaceAll("\\\\", "\\\\\\\\"), r.getTable()});
}
writer.flush();
writer.close();
// MyOntologyTrees.createRegexMenu();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return true;
}
示例5: writeTableToFile
import au.com.bytecode.opencsv.CSVWriter; //導入方法依賴的package包/類
public void writeTableToFile(JTable table, File file)
throws IOException {
final CSVWriter writer =
new CSVWriter(new PrintWriter(file, charEncoding), ',', '\"',
(OSInfo.isWindows() ? "\r\n" : "\n"));
// output column names
final String[] colnames = new String[table.getColumnCount()];
for(int i = 0; i < table.getColumnCount(); i++) {
colnames[i] = table.getColumnName(i);
}
writer.writeNext(colnames);
final String[] currentRow = new String[table.getColumnCount()];
for(int row = 0; row < table.getRowCount(); row++) {
for(int col = 0; col < table.getColumnCount(); col++) {
final Object cellVal = table.getValueAt(row, col);
currentRow[col] = (cellVal == null ? "" : cellVal.toString());
}
writer.writeNext(currentRow);
}
writer.flush();
writer.close();
}
示例6: printHeader
import au.com.bytecode.opencsv.CSVWriter; //導入方法依賴的package包/類
private void printHeader(CSVWriter wr) throws IOException {
String[] header = {
"Nome",
"Numero di nodi",
"Numero di archi",
"Coefficiente di clustering",
"Densita'",
"Grado massimo",
"Grado minimo",
"Grado medio",
"Componenti connesse"
};
wr.writeNext(header);
wr.flush();
}
示例7: getEmailExportExpired
import au.com.bytecode.opencsv.CSVWriter; //導入方法依賴的package包/類
@GET
@Path("{id}/export/expired")
public Response getEmailExportExpired(@PathParam("id") Id id, @Context HttpServletResponse response)
throws IOException {
response.setContentType("text/csv");
response.setHeader("Content-Disposition", "attachment; filename=\"expired-emails.csv\"");
PrintWriter printWriter = response.getWriter();
CSVWriter writer = new CSVWriter(printWriter, ';');
writer.writeNext(new String[] { "E-mail", "From", "To", "Used", "Code" });
// rom/to dates, used and coupon code
DiscountPromotion p = checked(service.get(DiscountPromotion.class, id));
if (p != null) {
Coupon c = p.getCoupon();
if (c != null) {
List<CouponCode> couponCodes = c.getCodes();
if (couponCodes != null) {
for (CouponCode couponCode : couponCodes) {
if (couponCode.getEmail() != null) {
String email = couponCode.getEmail();
if (couponCode.getCouponUsages() == null || couponCode.getCouponUsages().size() == 0) {
Date now = new Date();
Date fromDate = DateTimes.maxOfDates(c.getFromDate(), couponCode.getFromDate());
Date toDate = DateTimes.minOfDates(c.getToDate(), couponCode.getToDate());
if (toDate != null && toDate.before(now)) {
writer.writeNext(
new String[] { email, fromDate == null ? "" : csvDate.format(fromDate),
csvDate.format(toDate), "", couponCode.getCode() });
}
}
}
}
}
}
}
writer.flush();
writer.close();
return Response.ok().build();
}
開發者ID:geetools,項目名稱:geeCommerce-Java-Shop-Software-and-PIM,代碼行數:41,代碼來源:DiscountPromotionResource.java
示例8: getEmailExportAll
import au.com.bytecode.opencsv.CSVWriter; //導入方法依賴的package包/類
@GET
@Path("{id}/export/all")
public Response getEmailExportAll(@PathParam("id") Id id, @Context HttpServletResponse response)
throws IOException {
response.setContentType("text/csv");
response.setHeader("Content-Disposition", "attachment; filename=\"all.csv\"");
PrintWriter printWriter = response.getWriter();
CSVWriter writer = new CSVWriter(printWriter, ';');
writer.writeNext(new String[] { "E-mail", "From", "To", "Used", "Code" });
DiscountPromotion p = checked(service.get(DiscountPromotion.class, id));
if (p != null) {
Coupon c = p.getCoupon();
if (c != null) {
List<CouponCode> couponCodes = this.couponCodes.thatBelongTo(c);
if (couponCodes != null) {
for (CouponCode couponCode : couponCodes) {
String code = couponCode.getCode();
String email = couponCode.getEmail() == null ? Str.EMPTY : couponCode.getEmail();
String used = couponCode.getCouponUsages() != null && couponCode.getCouponUsages().size() > 0
? (couponCode.getCouponUsages().get(0).getUsageDate() != null
? csvDate.format(couponCode.getCouponUsages().get(0).getUsageDate()) : "---")
: "";
String exported = couponCode.getExportedDate() != null
? csvDate.format(couponCode.getExportedDate()) : "";
Date fromDate = DateTimes.maxOfDates(c.getFromDate(), couponCode.getFromDate());
Date toDate = DateTimes.minOfDates(c.getToDate(), couponCode.getToDate());
writer.writeNext(new String[] { email, fromDate == null ? "" : csvDate.format(fromDate),
toDate == null ? "" : csvDate.format(toDate), used, code });
}
}
}
}
writer.flush();
writer.close();
return Response.ok().build();
}
開發者ID:geetools,項目名稱:geeCommerce-Java-Shop-Software-and-PIM,代碼行數:41,代碼來源:DiscountPromotionResource.java
示例9: printBaseline
import au.com.bytecode.opencsv.CSVWriter; //導入方法依賴的package包/類
public void printBaseline(CSVWriter writer) {
String[] baseline = { "0", "0", "0", "0", "0", "0", "0" };
writer.writeNext(baseline);
try {
writer.flush();
} catch (IOException e) {
e.printStackTrace();
}
}
示例10: fillDistributionsCSV
import au.com.bytecode.opencsv.CSVWriter; //導入方法依賴的package包/類
private void fillDistributionsCSV(CSVWriter writer) throws IOException {
writer.writeNext(DISTRIBUTIONS_HEADER);
SortedSet<Long> times = new TreeSet<>(blockchainInfo.getTimeInfos().keySet());
for (Long time : times) {
SortedSet<Integer> sizes = new TreeSet<>(blockchainInfo.getTimeInfos().get(time).keySet());
for (Integer size : sizes) {
TimeInfo t = blockchainInfo.getTimeInfos().get(time).get(size);
String[] entry = {String.valueOf(time), String.valueOf(t.getTimeAndSize().getSizeSpan().getBlockSizeMin()),
String.valueOf(t.getTimeAndSize().getSizeSpan().getBlockSizeMax()),
String.valueOf(t.getMediumDstrbTime95()), String.valueOf(t.getMediumDstrbTime100())};
writer.writeNext(entry);
writer.flush();
}
}
}
示例11: fillNumberOfNodesCSV
import au.com.bytecode.opencsv.CSVWriter; //導入方法依賴的package包/類
private void fillNumberOfNodesCSV(CSVWriter writer) throws IOException {
writer.writeNext(NUMBER_OF_NODES_HEADER);
SortedSet<Long> times = new TreeSet<>(blockchainInfo.getTimeToNumNodes().keySet());
for (Long time : times) {
String[] entry = {String.valueOf(time), String.valueOf(blockchainInfo.getTimeToNumNodes().get(time))};
writer.writeNext(entry);
writer.flush();
}
}
示例12: fillIntensitiesCSV
import au.com.bytecode.opencsv.CSVWriter; //導入方法依賴的package包/類
private void fillIntensitiesCSV(CSVWriter writer) throws IOException {
writer.writeNext(INTENSIIES_HEADER);
SortedSet<Long> times = new TreeSet<>(blockchainInfo.getTimeToIntensities().keySet());
for (Long time : times) {
String[] entry = {String.valueOf(time), String.valueOf(blockchainInfo.getTimeToIntensities().get(time))};
writer.writeNext(entry);
writer.flush();
}
}
示例13: fillTransactionsCSV
import au.com.bytecode.opencsv.CSVWriter; //導入方法依賴的package包/類
private void fillTransactionsCSV(CSVWriter writer) throws IOException {
writer.writeNext(TRANSACTIONS_HEADER);
for (TransactionInfo transactionInfo : blockchainInfo.getTransactions().values()) {
String[] entry = {String.valueOf(transactionInfo.getTransactionId()),
String.valueOf(transactionInfo.getBlockId()),
String.valueOf(transactionInfo.getTransactionSize()),
String.valueOf(transactionInfo.getTime()),
String.valueOf(transactionInfo.getNodeId())};
writer.writeNext(entry);
writer.flush();
}
}
示例14: fillBlocksCSV
import au.com.bytecode.opencsv.CSVWriter; //導入方法依賴的package包/類
private void fillBlocksCSV(CSVWriter writer) throws IOException {
writer.writeNext(BLOCKS_HEADER);
for (BlockInfo blockDistributionInfo : blockchainInfo.getBlocks().values()) {
String[] entry = {String.valueOf(blockDistributionInfo.getBlockId()),
String.valueOf(blockDistributionInfo.getCreationTime()),
String.valueOf(blockDistributionInfo.getDistributionTime95()),
String.valueOf(blockDistributionInfo.getDistributionTime100()),
String.valueOf(blockDistributionInfo.getVerificationTime())};
writer.writeNext(entry);
writer.flush();
}
}
示例15: fillUnverifiedTransactionsCSV
import au.com.bytecode.opencsv.CSVWriter; //導入方法依賴的package包/類
private void fillUnverifiedTransactionsCSV(CSVWriter writer) throws IOException {
writer.writeNext(UNVERIFIED_HEADER);
SortedSet<Long> times = new TreeSet<>(blockchainInfo.getTimeToUnverifiedTransactions().keySet());
for (Long time : times) {
String[] entry = {String.valueOf(time), String.valueOf(blockchainInfo.getTimeToUnverifiedTransactions().get(time))};
writer.writeNext(entry);
writer.flush();
}
}