views:

14

answers:

0

My app makes multiple request to a web server via a static method, here is the method's body

try {
        DefaultHttpClient defaultHttpClient = new DefaultHttpClient();
        HttpPost httpPost = new HttpPost(url);
        httpPost.setHeader("Accept-Encoding", "gzip");

        List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();

        int pairsCount = 0;
        for(String key: keys) {
            nameValuePairs.add(new BasicNameValuePair(key, values[pairsCount]));
            ++pairsCount;
        }
        httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

        HttpResponse httpResponse = (HttpResponse)defaultHttpClient.execute(httpPost);
        HttpEntity httpEntity = httpResponse.getEntity();

        if(null != httpEntity) {
            InputStream inputStream = httpEntity.getContent();
            Header contentEncoding = httpResponse.getFirstHeader("Content-Encoding");
            if(contentEncoding != null && contentEncoding.getValue().equalsIgnoreCase("gzip")) {
                inputStream = new GZIPInputStream(inputStream);
                if(Constants.LOGGING)
                    Log.i(TAG, "Now using gzip compression.");
            }
            String resultString = convertStreamToString(inputStream);
            if(Constants.LOGGING)
                Log.i(TAG, resultString);
            inputStream.close();

i take the resultString and create a new JSONObject and do some parsing of it(insert some name/value pairs into a List<Map<String, String>> object. inside there you will see a method named convertStreamToString(inputStream);

here is the snippet of that method:

protected static String convertStreamToString(InputStream inputStream) {
    InputStreamReader isr = new InputStreamReader(inputStream, Charset.forName("UTF-8"));
    BufferedReader bufferedReader = new BufferedReader(isr, 2048);
    StringBuilder stringBuilder = new StringBuilder();
    String line = "";

    try {
        while((line = bufferedReader.readLine()) != null)
            stringBuilder.append(line + System.getProperty("line.separator"));
    }
    catch(IOException e) {
        if(Constants.LOGGING)
            Log.e(TAG, e.toString());
    }

my concern: i have found that while running this code, the LogCat prints out many messages: logcat tag: System.out logcat message: interface name: null

why is the system outputting this message? How can i avoid this? i don't want these messages printing out all the time

edit: seems like the logcat is only printing these messages while im doing the JSON parsing.. anyone have any insight?!