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


Java CSVWriter.writeNext方法代碼示例

本文整理匯總了Java中au.com.bytecode.opencsv.CSVWriter.writeNext方法的典型用法代碼示例。如果您正苦於以下問題:Java CSVWriter.writeNext方法的具體用法?Java CSVWriter.writeNext怎麽用?Java CSVWriter.writeNext使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在au.com.bytecode.opencsv.CSVWriter的用法示例。


在下文中一共展示了CSVWriter.writeNext方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: writeCSV

import au.com.bytecode.opencsv.CSVWriter; //導入方法依賴的package包/類
/**
 * Writes the data set to a CSV file
 * 
 * @param file
 * @param dataset
 * @throws IOException
 */
public void writeCSV(File file, DataSet<RecordType, SchemaElementType> dataset)
		throws IOException {
	CSVWriter writer = new CSVWriter(new FileWriter(file));

	String[] headers = getHeader(dataset);
	if(headers!=null) {
		writer.writeNext(headers);
	}

	for (RecordType record : dataset.get()) {
		String[] values = format(record, dataset);

		writer.writeNext(values);
	}

	writer.close();
}
 
開發者ID:olehmberg,項目名稱:winter,代碼行數:25,代碼來源:CSVDataSetFormatter.java

示例2: csv

import au.com.bytecode.opencsv.CSVWriter; //導入方法依賴的package包/類
/**
 * Dump out a VoltTable as a CSV to the given writer
 * If the header flag is set to true, then the output will include 
 * the column names in the first row
 * @param out
 * @param vt
 * @param write_header
 */
public static void csv(Writer out, VoltTable vt, boolean header) {
    CSVWriter writer = new CSVWriter(out);
    
    if (header) {
        String cols[] = new String[vt.getColumnCount()];
        for (int i = 0; i < cols.length; i++) {
            cols[i] = vt.getColumnName(i);
        } // FOR
        writer.writeNext(cols);
    }
    vt.resetRowPosition();
    while (vt.advanceRow()) {
        String row[] = vt.getRowStringArray();
        assert(row != null);
        assert(row.length == vt.getColumnCount());
        writer.writeNext(row);
    } // WHILE
}
 
開發者ID:s-store,項目名稱:sstore-soft,代碼行數:27,代碼來源:VoltTableUtil.java

示例3: exportDatabaseToCsvString

import au.com.bytecode.opencsv.CSVWriter; //導入方法依賴的package包/類
public synchronized String exportDatabaseToCsvString() {
    StringWriter stringWriter = new StringWriter();
    CSVWriter csvWriter = new CSVWriter(stringWriter);
    csvWriter.writeNext(ThreeThingsEntry.COLUMNS);

    SQLiteDatabase db = mDbHelper.getReadableDatabase();
    Cursor cursor = db.rawQuery("SELECT * FROM " + ThreeThingsEntry.TABLE_NAME, null);
    while (cursor.moveToNext()) {
        List<String> data = new ArrayList(ThreeThingsEntry.COLUMNS.length);
        for (String column : ThreeThingsEntry.COLUMNS) {
            data.add(cursor.getString(cursor.getColumnIndexOrThrow(column)));
        }
        csvWriter.writeNext(data.toArray(new String[0]));
    }

    try {
        csvWriter.close();
    } catch (IOException e) {
        // Ignore.
    }

    return stringWriter.toString();
}
 
開發者ID:stephenmcgruer,項目名稱:three-things-today,代碼行數:24,代碼來源:ThreeThingsDatabase.java

示例4: writeCSVfile

import au.com.bytecode.opencsv.CSVWriter; //導入方法依賴的package包/類
/**
 * Writes newly calculated and equally distributed vector data to user specified CSV file.
 *
 * @param list finalized vector data to write to user specified output file
 */
public static void writeCSVfile(List<List<String>> list) {
  String outputFile = myResultDir;
  boolean alreadyExists = new File(outputFile).exists();

  try {
    CSVWriter csvOutput = new CSVWriter(new FileWriter(outputFile), ','); // Create new instance of CSVWriter to write to file output

    if (!alreadyExists) {
      csvOutput.writeNext(myHeader); // Write the text headers first before data

      for (int i = 0; i < list.size(); i++) // Iterate through all rows in 2D array
      {
        String[] temp = new String[list.get(i).size()]; // Convert row array list in 2D array to regular string array
        temp = list.get(i).toArray(temp);
        csvOutput.writeNext(temp); // Write this array to the file
      }
    }

    csvOutput.close(); // Close csvWriter
  } catch (IOException e) {
    e.printStackTrace();
  }
}
 
開發者ID:apache,項目名稱:incubator-sdap-mudrod,代碼行數:29,代碼來源:DataGenerator.java

示例5: writeCSV

import au.com.bytecode.opencsv.CSVWriter; //導入方法依賴的package包/類
/**
 * Writes the data set to a CSV file
 * 
 * @param file
 * @param dataset
 * @throws IOException
 */
public void writeCSV(File file, Processable<RecordType> dataset)
		throws IOException {
	CSVWriter writer = new CSVWriter(new FileWriter(file));

	String[] headers = getHeader();
	if(headers!=null) {
		writer.writeNext(headers);
	}

	for (RecordType record : dataset.get()) {
		String[] values = format(record);

		writer.writeNext(values);
	}

	writer.close();
}
 
開發者ID:olehmberg,項目名稱:winter,代碼行數:25,代碼來源:CSVFormatter.java

示例6: writeSimpleWeightedGraph2CSV

import au.com.bytecode.opencsv.CSVWriter; //導入方法依賴的package包/類
public static void writeSimpleWeightedGraph2CSV(SimpleWeightedGraph<Long, DefaultWeightedEdge> colocationgraph,
		File file) throws IOException {
	CSVWriter writer = new CSVWriter(new FileWriter(file), ';');
	// write header
	String[] line = new String[4];
	line[0] = "source";
	line[1] = "target";
	line[2] = "weight";
	line[3] = "type";
	writer.writeNext(line);
	for (DefaultWeightedEdge e : colocationgraph.edgeSet()) {
		line = new String[4];
		line[0] = String.valueOf(colocationgraph.getEdgeSource(e).longValue() + (long) 111);
		line[1] = String.valueOf(colocationgraph.getEdgeTarget(e).longValue() + (long) 111);
		line[2] = String.valueOf(colocationgraph.getEdgeWeight(e));
		line[3] = "undirected";
		writer.writeNext(line);
	}
	writer.close();
}
 
開發者ID:IGNF,項目名稱:geoxygene,代碼行數:21,代碼來源:SocialGraph.java

示例7: testWrite

import au.com.bytecode.opencsv.CSVWriter; //導入方法依賴的package包/類
@Test
public void testWrite() throws IOException { 
  String[] row1 = new String[] { "oneone", "onetwo", "onethree" };
  String[] row2 = new String[] { "twoone", "twotwo", "twothree" };

  StringWriter sWriter = new StringWriter();
  CSVWriter writer = new CSVWriter(sWriter, ',', '\'');

  writer.writeNext(row1);
  writer.writeNext(row2);

  String written = sWriter.toString();

  CSVReader reader = new CSVReader(new StringReader(written), ',', '\'');
  List<String[]> rows = reader.readAll();
  assertTrue(Arrays.equals(rows.get(0), row1));
  assertTrue(Arrays.equals(rows.get(1), row2));
}
 
開發者ID:casific,項目名稱:murmur,代碼行數:19,代碼來源:OpenCSVTest.java

示例8: 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

示例9: dumpSecurityStructure

import au.com.bytecode.opencsv.CSVWriter; //導入方法依賴的package包/類
private void dumpSecurityStructure(CSVWriter csvWriter, String securityType, ManageableSecurity firstSecurity) {
  if (firstSecurity == null) {
    s_logger.error("null security passed to dumpSecurityStructure");
    return;
  }
  s_logger.info("Processing security " + firstSecurity);
  csvWriter.writeNext(new String[] {securityType });
  csvWriter.writeNext(new String[] {firstSecurity.metaBean().beanName() });
  csvWriter.writeNext(new String[] {"Type", "Name", "Example"});
  Iterable<MetaProperty<?>> metaPropertyIterable = firstSecurity.metaBean().metaPropertyIterable();
  for (MetaProperty<?> metaProperty : metaPropertyIterable) {
    s_logger.info("Field" + metaProperty.name());
    String strValue;
    try {
      strValue = metaProperty.getString(firstSecurity);
    } catch (IllegalStateException ise) {
      strValue = metaProperty.get(firstSecurity).toString();
    }
    csvWriter.writeNext(new String[] {metaProperty.propertyType().getSimpleName(), metaProperty.name(), strValue });
  }
  csvWriter.writeNext(new String[] {});
}
 
開發者ID:DevStreet,項目名稱:FinanceAnalytics,代碼行數:23,代碼來源:SecurityFieldMappingTemplateGenerator.java

示例10: CsvSheetWriter

import au.com.bytecode.opencsv.CSVWriter; //導入方法依賴的package包/類
public CsvSheetWriter(String filename, String[] columns) {

    ArgumentChecker.notEmpty(filename, "filename");
    ArgumentChecker.notNull(columns, "columns");

    // Open file
    OutputStream fileOutputStream = openFile(filename);

    // Set up CSV Writer
    _csvWriter = new CSVWriter(new OutputStreamWriter(fileOutputStream));
    
    // Set columns
    setColumns(columns);
    
    // Write the column row
    _csvWriter.writeNext(columns);
    flush();
  }
 
開發者ID:DevStreet,項目名稱:FinanceAnalytics,代碼行數:19,代碼來源:CsvSheetWriter.java

示例11: writeInternal

import au.com.bytecode.opencsv.CSVWriter; //導入方法依賴的package包/類
@Override
protected void writeInternal(QuoteWrapper quotes, HttpOutputMessage httpOutputMessage) throws IOException, HttpMessageNotWritableException {
    CSVWriter writer = new CSVWriter(new OutputStreamWriter(httpOutputMessage.getBody()));
    for (YahooQuote quote : quotes) {
        writer.writeNext(
        		new String[]{	quote.getId(),
        						quote.getName(),
        						String.valueOf(quote.getOpen()),
        						String.valueOf(quote.getPreviousClose()),
                				String.valueOf(quote.getLast()),
                        		String.valueOf(quote.getLastChange()),
                        		String.valueOf(quote.getLastChangePercent()),
                        		String.valueOf(quote.getHigh()),
                        		String.valueOf(quote.getLow()),
                        		String.valueOf(quote.getBid()),
                        		String.valueOf(quote.getAsk()),
                        		String.valueOf(quote.getVolume()),
        						quote.getExchange(),
        						quote.getCurrency()
        		});
    }

    writer.close();
}
 
開發者ID:alex-bretet,項目名稱:cloudstreetmarket.com,代碼行數:25,代碼來源:YahooHistoMessageConverter.java

示例12: 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

示例13: writeCSV

import au.com.bytecode.opencsv.CSVWriter; //導入方法依賴的package包/類
public void writeCSV(File file) throws IOException {
   	FileWriter writer = new FileWriter(file);
   	CSVWriter csvWriter = new CSVWriter(writer);
   	
	for (QueryLogValue query : queryLogStatistic.getLastQueries()) {
		String[] cols = new String[] {
				String.valueOf(query.isError()),
				query.getQueryString(),
				query.getFacetQueryString(),
				query.getFilterQueryString(),
				query.getQTime().toString(),
				query.getResults().toString()
		};
		csvWriter.writeNext(cols);
	}
	
	csvWriter.close();
}
 
開發者ID:lafourchette,項目名稱:solrmeter,代碼行數:19,代碼來源:FullQueryStatisticController.java

示例14: write

import au.com.bytecode.opencsv.CSVWriter; //導入方法依賴的package包/類
public boolean write(MappingStrategy<T> mapper, CSVWriter csv,
                     List<?> objects) {
    if (objects == null || objects.isEmpty())
        return false;

    try {
        csv.writeNext(processHeader(mapper));
        List<Method> getters = findGetters(mapper);
        for (Object obj : objects) {
            String[] line = processObject(getters, obj);
            csv.writeNext(line);
        }
        return true;
    } catch (Exception e) {
        throw new RuntimeException("Error writing CSV !", e);
    }
}
 
開發者ID:mekterovic,項目名稱:bactimas,代碼行數:18,代碼來源:BeanToCsv.java

示例15: write

import au.com.bytecode.opencsv.CSVWriter; //導入方法依賴的package包/類
@Override
public void write(CSVWriter csvWriter, List<Player> models) {
    csvWriter.writeNext(new String[]{
            "id",
            "birthDate",
            "region",
            "country",
            "gender",
            "externalId",
            "customData"
    });

    for(Player model : models) {
        csvWriter.writeNext(new String[]{
                model.getId().toString(),
                CsvHelper.formatDate(model.getBirthDate()),
                model.getRegion(),
                model.getCountry(),
                model.getGender() != null ? model.getGender().name() : null,
                model.getExternalId(),
                model.getCustomData()
        });
    }
}
 
開發者ID:CyberCRI,項目名稱:RedMetrics,代碼行數:25,代碼來源:PlayerCsvEntityConverter.java


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