Advertisement
INSECURE-FLOWERPOT

Untitled

Mar 27th, 2015
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. BufferedReader brCities = new BufferedReader(new FileReader("cities.csv"));
  2. BufferedReader brPeopleList = new BufferedReader(new FileReader("players7.csv"));
  3. //Players
  4. ArrayList<State>states = new ArrayList<State>();
  5. ArrayList<String>peopleLine=new ArrayList<String>();
  6. HashMap<String,String>hash=new HashMap<String,String>();
  7.  
  8. String cities = brCities.readLine();
  9. String peopleList = brPeopleList.readLine();
  10.  
  11. while(cities!=null&&peopleList != null)
  12. {
  13.  
  14. String[]citiesTokens=cities.split("; ");
  15. if(citiesTokens.length == 4)
  16. {
  17. String cityState=citiesTokens[0]+","+citiesTokens[1];
  18. String latLong=citiesTokens[2]+","+citiesTokens[3];
  19. hash.put(cityState, latLong);
  20.  
  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.  
  51. s.addPeople(peopleLine.get(i));
  52. }
  53. }
  54. else
  55. {
  56. states.add(new State(tokens[2],tokens[3],peopleLine.get(i),hash.get(tokens[2]+","+tokens[3])));
  57. }
  58. }
  59. else
  60. {
  61. states.add(new State(tokens[2],tokens[3],peopleLine.get(i),hash.get(tokens[2]+","+tokens[3])));
  62. }
  63.  
  64. }
  65.  
  66. brCities.close();
  67. brPeopleList.close();
  68. query(states);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement