Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phuongtailtranminh/5fc130605879483cefda633f560e25ad to your computer and use it in GitHub Desktop.
Save phuongtailtranminh/5fc130605879483cefda633f560e25ad to your computer and use it in GitHub Desktop.
public class VasgateParser {
private static final Logger log = LoggerFactory.getLogger(VasgateParser.class);
private final String fileName;
private static final int INDEX_OF_PHONE_NUMBER = 0;
public VasgateParser(String fileName) {
this.fileName = fileName;
}
public List<String> getListPhoneNumber() {
List<String> listPhoneNumber = new ArrayList<String>();
Reader in = null;
try {
in = new FileReader(fileName);
Iterable<CSVRecord> records = CSVFormat.RFC4180.parse(in);
for (CSVRecord record : records) {
String phoneNumber = record.get(INDEX_OF_PHONE_NUMBER);
listPhoneNumber.add(phoneNumber);
}
} catch (Exception e) {
e.printStackTrace();
log.error(e.getMessage());
} finally {
try {
in.close();
} catch (IOException e) {
e.printStackTrace();
log.error(e.getMessage());
}
}
return listPhoneNumber;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment