0

Here I have the desired format that I want my locations to appear as.

private HashMap<String, Location> loadLocationData()
{
    HashMap<String, Location> locations = new HashMap<String, Location>();

    locations.put("Paris", new Location("Paris",48.8566,2.3522,TimeZone.getTimeZone("France/Paris")));
    locations.put("Rome", new Location("Rome",41.9028,12.4964,TimeZone.getTimeZone("Italy/Rome")));

    return locations;
}

Here is the text file which I want to read from, with the lines of data in this format:

Paris,48.8566,2.3522,France/Paris
Rome,41.9028,12.4964,Italy/Rome

Basically, I need to be able to read the text file, and then somehow insert that text into the format I have in the first block of code I posted.

If someone could help me with the best way to do this I will be very thankful. Also note, when I'm adding a new location to the list, the name of the city needs to be repeated, as it is a key-value set.

  • the text file is a csv file and there are many questions on here that tackle that problem: http://stackoverflow.com/questions/6057695/how-to-parse-the-csv-file-in-android-application – Steven Stip Oct 28 '16 at 04:49
  • Check this [How to read a large text file line by line using Java?](http://stackoverflow.com/questions/5868369/how-to-read-a-large-text-file-line-by-line-using-java) – Raghavendra Oct 28 '16 at 04:56

0 Answers0