Java Code Examples for au.com.bytecode.opencsv.CSVWriter.DEFAULT_SEPARATOR

The following are Jave code examples for showing how to use DEFAULT_SEPARATOR of the au.com.bytecode.opencsv.CSVWriter class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: fhaes   File: CategoryEditor.java   Source Code and License Vote up 5 votes
/**
 * Writes all category entries to the specified csv file.
 * 
 * @param filePath
 */
private void saveCategoriesToFile(String filePath) {
	
	try
	{
		CSVWriter writer = new CSVWriter(new FileWriter(filePath), CSVWriter.DEFAULT_SEPARATOR, CSVWriter.NO_QUOTE_CHARACTER, "\r\n");
		ArrayList<FHCategoryEntry> categoryEntries = getAllCategoryEntries();
		
		String[] headerLine = new String[FHCategoryReader.NUM_COLUMNS_IN_FILE];
		headerLine[FHCategoryReader.INDEX_OF_HEADER] = FHCategoryReader.FHAES_CATEGORY_FILE_HEADER;
		headerLine[FHCategoryReader.INDEX_OF_VERSION] = FHCategoryReader.FHAES_CATEGORY_FILE_VERSION;
		headerLine[FHCategoryReader.INDEX_OF_FILENAME] = workingFile.getFileNameWithoutExtension();
		writer.writeNext(headerLine);
		
		for (int i = 0; i < categoryEntries.size(); i++)
		{
			String[] nextLine = new String[FHCategoryReader.NUM_COLUMNS_IN_FILE];
			nextLine[FHCategoryReader.INDEX_OF_SERIES_TITLE] = categoryEntries.get(i).getSeriesTitle();
			nextLine[FHCategoryReader.INDEX_OF_CATEGORY] = categoryEntries.get(i).getCategory();
			nextLine[FHCategoryReader.INDEX_OF_CONTENT] = categoryEntries.get(i).getContent();
			writer.writeNext(nextLine);
		}
		
		writer.close();
		
		MainWindow.getInstance().getFeedbackMessagePanel().updateFeedbackMessage(FeedbackMessageType.INFO,
				FeedbackDisplayProtocol.AUTO_HIDE, FeedbackDictionary.CATEGORY_FILE_SAVED_MESSAGE.toString());
	}
	catch (IOException ex)
	{
		ex.printStackTrace();
	}
}