我目前正在使用GoogleMaps API,并试图将数据保存在LinkedHashLists的HashMap中。但是,某些数据点给我带来了麻烦,我在下面将它们与我的代码一同附加了。
数据点(ID /位置/ x / y / lat / long / ref / id / type):
ChIJCw_yGxBawokRhteO-nIiN7A,gatewayinformatics,3,12,40.70975060000001,-74.01785,1f80cbc9f4efd1853e41f0b3e753609e5290fbf3,CmRSAAAApHHt97PjYTzFp1RItf_Zo0LKRB2Fz98n65e-PSgcH4QdAhntqRIsfgM5PKzrRfpomIE9d9Lfqd8RYitN0_HtJCgaIuAb-j50PYsOtWLEOOKYxhwKmNBe0nM2pewHE1SdEhABzxoWdOc9-is5n_yspkF9GhRbCkfN3bX4dWykq97a7iaL2_mnPA,point_of_interest
ChIJCw_yGxBawokRhteO-nIiN7A,gatewayinformatics,3,12,40.70975060000001,-74.01785,1f80cbc9f4efd1853e41f0b3e753609e5290fbf3,CmRSAAAApHHt97PjYTzFp1RItf_Zo0LKRB2Fz98n65e-PSgcH4QdAhntqRIsfgM5PKzrRfpomIE9d9Lfqd8RYitN0_HtJCgaIuAb-j50PYsOtWLEOOKYxhwKmNBe0nM2pewHE1SdEhABzxoWdOc9-is5n_yspkF9GhRbCkfN3bX4dWykq97a7iaL2_mnPA,establishment
ChIJCw_yGxBawokRlM3x9kRBn3o,SPECIALCHARACTERS,3,12,40.70975060000001,-74.01785,3c8e47643b57a86f1a3761c14d6cd4775103bc78,CmRRAAAAodXhQRbSmP62RkYOcPF2hGO_u1sNHv3ji5z-7hRx9M3SSK-_ZKyCcnwabzZd-eYc16-e_rtgv7rpOBWpyq80WN9lN8wBMa0AgEgnimJz7PupYtZQKWMclqS4vqA5EEyHEhCKpFlLtLpUXrpTit3fq1VCGhQLgKR7fvHymzc9Bq2iYOCt_5u38A,restaurant
ChIJCw_yGxBawokRlM3x9kRBn3o,SPECIALCHARACTERS,3,12,40.70975060000001,-74.01785,3c8e47643b57a86f1a3761c14d6cd4775103bc78,CmRRAAAAodXhQRbSmP62RkYOcPF2hGO_u1sNHv3ji5z-7hRx9M3SSK-_ZKyCcnwabzZd-eYc16-e_rtgv7rpOBWpyq80WN9lN8wBMa0AgEgnimJz7PupYtZQKWMclqS4vqA5EEyHEhCKpFlLtLpUXrpTit3fq1VCGhQLgKR7fvHymzc9Bq2iYOCt_5u38A,food
班级代码
places.put("TID", tid);
places.put("LOCATIONID", LocationID);
places.put("LOCATION", loc);
places.put("X", x);
places.put("Y", y);
places.put("LAT", lat);
places.put("LNG", lng);
places.put("ID", id);
places.put("REF", ref);
places.put("TYPE", type);
int index = 0;
try{
inFile = new Scanner(new FileInputStream(PlacesFinal));
}
catch(FileNotFoundException exception){
}
while(inFile.hasNextLine()){
places.get("TID").add(Integer.toString(index));
index++;
String info = inFile.nextLine();
StringTokenizer st = new StringTokenizer(info);
while(st.hasMoreTokens()){
places.get("LOCATIONID").add((st.nextToken(",")));
if (!st.hasMoreElements()) break;
places.get("LOCATION").add(st.nextToken(","));
if (!st.hasMoreElements()) break;
places.get("X").add((st.nextToken(",")));
if (!st.hasMoreElements()) break;
places.get("Y").add((st.nextToken(",")));
if (!st.hasMoreElements()) break;
places.get("LAT").add((st.nextToken(",")));
if (!st.hasMoreElements()) break;
places.get("LNG").add((st.nextToken(",")));
if (!st.hasMoreElements()) break;
places.get("ID").add((st.nextToken(",")));
if (!st.hasMoreElements()) break;
places.get("REF").add((st.nextToken(",")));
if (!st.hasMoreElements()) break;
places.get("TYPE").add((st.nextToken(",")));
}
}
测试点似乎StringTokenizer会跳过Location数据字段并直接转到x,但是我不知道为什么