Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.github.jreddit.utils.restclient;
 
 import  org.apache.commons.io.IOUtils;
 
public class RestResponseHandler implements ResponseHandler<Response> {
    private final JSONParser jsonParser;
    public RestResponseHandler() {
        this. = new JSONParser();
    }
    public RestResponseHandler(JSONParser jsonParser) {
        this. = jsonParser;
    }
        try {
            return parse(response);
        }
        catch (ParseException e) {
            ..println("Error parsing response from Reddit");
        }
        return null;
    }
    private Response parse(HttpResponse httpResponsethrows IOExceptionParseException {
        InputStream responseStream = null;
        try{
            responseStream = httpResponse.getEntity().getContent();
            String content = IOUtils.toString(responseStream"UTF-8");
            Object responseObject = .parse(content);
            return new RestResponse(contentresponseObjecthttpResponse);
        }finally{
            IOUtils.closeQuietly(responseStream);
        }
    }
New to GrepCode? Check out our FAQ X