當前位置: 首頁>>代碼示例>>Java>>正文


Java CSVWriter.flush方法代碼示例

本文整理匯總了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());
	}
}
 
開發者ID:tesis-dynaware,項目名稱:fancy-chart,代碼行數:19,代碼來源:CsvDao.java

示例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();
}
 
開發者ID:geetools,項目名稱:geeCommerce-Java-Shop-Software-and-PIM,代碼行數:23,代碼來源:CustomerResource.java

示例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();
	}
}
 
開發者ID:michelole,項目名稱:ICDClassifier,代碼行數:23,代碼來源:ExperimentalCipeClassifier.java

示例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;
	}
 
開發者ID:tmfev,項目名稱:IDRT-Import-and-Mapping-Tool,代碼行數:20,代碼來源:RegexWizard.java

示例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();
}
 
開發者ID:phon-ca,項目名稱:phon,代碼行數:24,代碼來源:CSVTableDataWriter.java

示例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();
}
 
開發者ID:isislab-unisa,項目名稱:streaminggraphpartitioning,代碼行數:16,代碼來源:AllGraphDetails.java

示例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();
	}
}
 
開發者ID:michelole,項目名稱:ICDClassifier,代碼行數:10,代碼來源:ExperimentalCipeClassifier.java

示例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();
        }
    }
}
 
開發者ID:dsx-tech,項目名稱:blockchain-benchmarking,代碼行數:16,代碼來源:CSVComposer.java

示例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();
    }
}
 
開發者ID:dsx-tech,項目名稱:blockchain-benchmarking,代碼行數:10,代碼來源:CSVComposer.java

示例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();
    }
}
 
開發者ID:dsx-tech,項目名稱:blockchain-benchmarking,代碼行數:10,代碼來源:CSVComposer.java

示例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();
    }
}
 
開發者ID:dsx-tech,項目名稱:blockchain-benchmarking,代碼行數:13,代碼來源:CSVComposer.java

示例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();
    }
}
 
開發者ID:dsx-tech,項目名稱:blockchain-benchmarking,代碼行數:13,代碼來源:CSVComposer.java

示例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();
    }
}
 
開發者ID:dsx-tech,項目名稱:blockchain-benchmarking,代碼行數:10,代碼來源:CSVComposer.java


注:本文中的au.com.bytecode.opencsv.CSVWriter.flush方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。