public Map<String, String> readCsv(String csvName) { BufferedReader br = null; String line = ""; String cvsSplitBy = ","; String csvFileName = csvName; Map<String, String> abcCsv = new HashMap<>(); InputStream inputStream = getClass().getClassLoader().getResourceAsStream(csvFileName); try { br = new BufferedReader(new InputStreamReader(inputStream)); while ((line = br.readLine()) != null) { String[] abc = line.split(cvsSplitBy); abcCsv.put( (abc[0]).trim().replaceAll(REP1, "").replaceAll(REP2, " ").replaceAll(REP6, ""), (abc[1]).trim().replaceAll(REP1, "").replaceAll(REP2, " ").replaceAll(REP7, "") .replaceAll(REP4, "")); } } catch (FileNotFoundException e) { LOGGER.error("File not found exception thrown ", e); } catch (IOException e) { LOGGER.error("I/O exception thrown ", e); } catch (ArrayIndexOutOfBoundsException e) { LOGGER.error("Array index out of bounds."); } finally { if (br != null) { try { br.close(); } catch (IOException e) { LOGGER.error("I/O exception thrown ", e); } } } return abcCsv; }
.getResourceAsStream(csvFileName)
inputStream
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)