Advertisement
INSECURE-FLOWERPOT

Untitled

Mar 25th, 2015
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. public static void main(String[]args)throws IOException
  2. {
  3. BufferedReader br = new BufferedReader(new FileReader("PeopleList.csv"));
  4. String line,city,state;
  5. String delim="[,]";
  6. String del="[ ]";
  7. ArrayList<Place> place=new ArrayList<Place>();
  8. //Place fakePlace=new Place();
  9. //place.add(fakePlace);
  10. line=br.readLine();
  11. while(line != null)
  12. {
  13.  
  14. String[]tokens = line.split(delim);
  15.  
  16. if(tokens.length==4)
  17. {
  18. String[]tok=tokens[0].split(del);
  19. //START HERE
  20. if(!place.isEmpty())
  21. {
  22. //does this place exist?
  23.  
  24. int x = -1;
  25. //loop through all places and do manual check for place name
  26. for(int i=0; i<place.size(); i++)
  27. {
  28. Place lugar = place.get(i);
  29. if(lugar.getState().equals(tokens[3]))
  30. {
  31. x = i;
  32. break;
  33. }
  34. }
  35. if(x>=0)
  36. {
  37. //it does exist, add the city and state to that place
  38. Place lugar = place.get(x);
  39. lugar.addCity(tokens[2]);
  40. lugar.addPeople(line);//(tok[0]+" "+tok[1]+" "+tok[tok.length-1]));
  41. }
  42. else
  43. {
  44. place.add(new Place(tokens[2],tokens[3],line));//tok[0],tok[1],tok[tok.length-1]));
  45. }
  46.  
  47. /*
  48. if(!place.contains(tokens[3]))
  49. {
  50.  
  51. place.add(new Place(tokens[2],tokens[3],tok[0],tok[1],tok[tok.length-1]));
  52. }
  53. else
  54. {
  55. System.out.println("?");
  56. place.add(new Place(tokens[2],tok[0],tok[1],tok[tok.length-1]));
  57.  
  58. }
  59. */
  60. }
  61. else
  62. {
  63.  
  64. place.add(new Place(tokens[2],tokens[3],line));//tok[0],tok[1],tok[tok.length-1]));
  65. }
  66. /*
  67. * if(!this.city.contains(city))
  68. {
  69. this.city.add(city);
  70. }
  71. */
  72.  
  73.  
  74.  
  75. }
  76. else if(tokens.length==5)
  77. {
  78.  
  79.  
  80. }
  81. line=br.readLine();
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement