I am building recursive function that go through a million line or so, I get stackOverFlow from this function during execution.
protected String[] getConnectedCities(String line) {
return line.trim().toLowerCase().replace(DELIMITER + " ", DELIMITER)
.split(DELIMITER);
}
This is the full code:
protected final Map<String, City> processLine(
final Map<String, City> dataMap) {
try {
String line = "";
if ((line = bReader.readLine()) == null) {
return dataMap;
}
// Check if direct relation can be found
String connectedCities[] = parseLine(line);
line = null;
saveConnection(dataMap, connectedCities);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return processLine(dataMap);
}
I am not sure what am I doing wrong, I think it is related to the String line but am not quite sure what is it.
Thanks.