Advertisement
Guest User

Untitled

a guest
Jun 21st, 2018
416
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1.  
  2. // Assignment 2 Begins Here.
  3.  
  4. String latitude = new String();
  5. String longitute = new String();
  6. JSONObject one;
  7. File file2 = new File(
  8. "C:\\Users\\hiba\\eclipse-workspace\\CST8284\\src\\Assignment1\\output\\OutputAddresses.csv");
  9. try {
  10.  
  11. BufferedReader txt1 = new BufferedReader(new FileReader(file2));
  12.  
  13. BufferedWriter out1 = new BufferedWriter(new FileWriter(
  14. "C:\\Users\\hiba\\eclipse-workspace\\CST8284\\src\\Assignment1\\output\\LongLat.csv"));
  15.  
  16. ArrayList<Person> persons = new ArrayList<Person>();
  17. ArrayList<Address> addresses = new ArrayList<Address>();
  18.  
  19. while (txt1.readLine() != null) {
  20.  
  21.  
  22. one = new JSONObject();
  23. Person newPerson = new Person();
  24. Address newAddress = new Address();
  25. String[] line = txt1.readLine().split(",");
  26. newPerson.setFirstName(line[0]);
  27. newPerson.setLastName(line[1]);
  28. newPerson.setSpouseFirstName(line[2]);
  29. newPerson.setSpouseLastName(line[3]);
  30. newAddress.setStreetName(line[4]);
  31. newAddress.setStreetType(line[5]);
  32. newAddress.setProvince(line[6]);
  33. newAddress.setStreetOrientation(line[7]);
  34. newAddress.setCityName(line[8]);
  35. newAddress.setProvince(line[9]);
  36. persons.add(newPerson);
  37. addresses.add(newAddress);
  38. }
  39. URL url1 = new URL(
  40. "https://maps.googleapis.com/maps/api/geocode/json?address={address]AIzaSyAgSX7ZAI1PrUDMs2Djmv0YYmVTpk2y4GQ");
  41. HttpURLConnection con =
  42. (HttpURLConnection) url1.openConnection();
  43. txt1.close();
  44. out1.close();
  45. } catch (ArrayIndexOutOfBoundsException exception) {
  46. exception.printStackTrace();
  47. }
  48. txt.close();
  49. out.close();
  50.  
  51. } catch (Exception exception) {
  52. exception.printStackTrace();
  53. }
  54.  
  55. }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement