Java Code Examples for org.supercsv.io.CsvBeanReader#getHeader()

The following examples show how to use org.supercsv.io.CsvBeanReader#getHeader() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Utilities.java    From pegasus with Apache License 2.0 6 votes vote down vote up
/**
 * Read file sizes from CSV file.
 *
 * @param csvName CSV file name.
 * @throws IOException
 */
public static void loadHashMap(String csvName) throws IOException {
    final CellProcessor[] processors =
            new CellProcessor[] {null, null, null, null, new ParseLong()};
    CsvBeanReader beanReader =
            new CsvBeanReader(new FileReader(csvName), CsvPreference.STANDARD_PREFERENCE);
    final String[] header = beanReader.getHeader(true);
    FileDataBean fileDataBean;
    sizes = new HashMap<String, Long>();
    while ((fileDataBean = beanReader.read(FileDataBean.class, header, processors)) != null) {
        Long currentSize = sizes.get(fileDataBean.filename);
        if (currentSize != null) {
            assert (fileDataBean.length == currentSize);
        }
        sizes.put(fileDataBean.filename, fileDataBean.length);
    }
}
 
Example 2
Source File: CacheLoader.java    From geode-demo-application with Apache License 2.0 5 votes vote down vote up
private void initalizeBeanReader(String file) {
	beanReader = new CsvBeanReader(new BufferedReader(new InputStreamReader(getClass().getClassLoader().getResourceAsStream(file))),CsvPreference.STANDARD_PREFERENCE);
	try {
		@SuppressWarnings("unused")
		final String[] header = beanReader.getHeader(true);
	} catch (IOException e1) {
		e1.printStackTrace();
	}
}
 
Example 3
Source File: CacheLoader.java    From geode-demo-application with Apache License 2.0 5 votes vote down vote up
private void initalizeBeanReader(String file) {
	beanReader = new CsvBeanReader(new BufferedReader(
			new InputStreamReader(getClass().getClassLoader()
					.getResourceAsStream(file))),
			CsvPreference.STANDARD_PREFERENCE);
	try {
		@SuppressWarnings("unused")
		final String[] header = beanReader.getHeader(true);
	} catch (IOException e1) {
		errorLog.add(e1.toString());
	}
}