package com.google.maps.android.utils.demo;

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 {

    public List<MyItem> read(InputStream inputStream) throws JSONException {
        List<MyItem> items = new ArrayList<MyItem>();
        String json = new Scanner(inputStream).useDelimiter("\\A").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;
    }
}

@@ -317,16 +317,262 @@
 ader %7B%0A%0A
+    /*%0A     * This matches only once in whole input,%0A     * so Scanner.next returns whole InputStream as a String.%0A     * http://stackoverflow.com/a/5445161/2183804%0A     */%0A    private static final String REGEX_INPUT_BOUNDARY_BEGINNING = %22%5C%5CA%22;%0A%0A
     publ
@@ -754,21 +754,46 @@
 limiter(
-%22%5C%5CA%22
+REGEX_INPUT_BOUNDARY_BEGINNING
 ).next()

comment on the Scanner usage to convert InputStream to String