Please try to do anything on your own next time or describe your problem more concrete.
For example:
I try the CsvPreference.xyz but it didn't work, because I get the exception abc
Some basic stuff:
CSV = Comma-separated values
You file isn't seperated with comma or semicolon, its seperated with tabs.
So you have to create your own CsvPreference:
CsvPreference pref = new CsvPreference('\"', '\t', "\n");
Here is the full example (tested):
InputStream inputStream = this.getClassLoader().getResourceAsStream("example.csv");
CsvPreference pref = new CsvPreference('\"', '\t', "\n");
ICsvMapReader reader = new CsvMapReader(new InputStreamReader(inputStream), pref);
List<Map<String, String>> list = new ArrayList<Map<String, String>>();
Map<String, String> result;
while ((result = reader.read(new String[]{"code", "name"})) != null) {
list.add(result);
}
for (Map<String, String> elem : list) {
System.out.print(elem.get("code")+" | ");
System.out.print(elem.get("name"));
System.out.println();
}
Output:
110000 | Management Occupations
130000 | Business and Financial Operations Occupations
150000 | Computer and Mathematical Occupations