Advertisement
INSECURE-FLOWERPOT

Untitled

Mar 27th, 2015
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. public static void main(String[]args)throws IOException
  2. {
  3. BufferedReader brCities = new BufferedReader(new FileReader("cities.csv"));
  4. BufferedReader brPeopleList = new BufferedReader(new FileReader("PeopleList.csv"));
  5. //Players
  6. ArrayList<State>states = new ArrayList<State>();
  7. ArrayList<String>peopleLine=new ArrayList<String>();
  8. HashMap<String,String>hash=new HashMap<String,String>();
  9.  
  10. String cities = brCities.readLine();
  11. String peopleList = brPeopleList.readLine();
  12.  
  13. while(cities!=null&&peopleList != null)
  14. {
  15. String[]citiesTokens=cities.split("; ");
  16. if(citiesTokens.length == 4)
  17. {
  18. String cityState=citiesTokens[0]+","+citiesTokens[1];
  19. String latLong=citiesTokens[2]+","+citiesTokens[3];
  20. hash.put(cityState, latLong);
  21. peopleLine.add(peopleList);
  22. }
  23. cities=brCities.readLine();
  24. peopleList=brPeopleList.readLine();
  25.  
  26. }
  27.  
  28. for(int i=0; i<peopleLine.size();i++)
  29. {
  30. String[]tokens=peopleLine.get(i).split(",");
  31. if(tokens.length ==4 || tokens.length ==5)
  32. {
  33. int x=-1;
  34. for(int j=0; j<states.size(); j++)
  35. {
  36. State s= states.get(j);
  37. if(s.getState().equals(tokens[3]))
  38. {
  39. x=j;
  40. break;
  41. }
  42. }
  43. if(x>=0)
  44. {
  45. State s=states.get(x);
  46. if(hash.containsKey(tokens[2]+","+tokens[3]))
  47. {
  48. String latLong= hash.get(tokens[2]+","+tokens[3]);
  49. s.addCity(tokens[2],latLong);
  50. s.addPeople(peopleLine.get(i));
  51. }
  52. }
  53. else
  54. {
  55. states.add(new State(tokens[2],tokens[3],peopleLine.get(i),hash.get(tokens[2]+","+tokens[3])));
  56. }
  57. }
  58. else
  59. {
  60. states.add(new State(tokens[2],tokens[3],peopleLine.get(i),hash.get(tokens[2]+","+tokens[3])));
  61. }
  62.  
  63. }
  64.  
  65. brCities.close();
  66. brPeopleList.close();
  67. query(states);
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement