Back to project page android-maps-utils.
The source code is released under:
Apache License
If you think the Android project android-maps-utils listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.google.maps.android.utils.demo; // w ww .ja va2 s. c om import java.io.InputStream; import java.util.ArrayList; import java.util.List; import java.util.Scanner; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import com.google.maps.android.utils.demo.model.MyItem; public class MyItemReader { /* * This matches only once in whole input, * so Scanner.next returns whole InputStream as a String. * http://stackoverflow.com/a/5445161/2183804 */ private static final String REGEX_INPUT_BOUNDARY_BEGINNING = "\\A"; public List<MyItem> read(InputStream inputStream) throws JSONException { List<MyItem> items = new ArrayList<MyItem>(); String json = new Scanner(inputStream).useDelimiter(REGEX_INPUT_BOUNDARY_BEGINNING).next(); JSONArray array = new JSONArray(json); for (int i = 0; i < array.length(); i++) { JSONObject object = array.getJSONObject(i); double lat = object.getDouble("lat"); double lng = object.getDouble("lng"); items.add(new MyItem(lat, lng)); } return items; } }