public static Map<String, String> parseAsQueryString(HttpResponse response)
throws DropboxException {
HttpEntity entity = response.getEntity();
if (entity == null) {
throw new DropboxParseException("Bad response from Dropbox.");
}
Scanner scanner;
try {
scanner = new Scanner(entity.getContent()).useDelimiter("&");
} catch (IOException e) {
throw new DropboxIOException(e);
}
Map<String, String> result = new HashMap<String, String>();
while (scanner.hasNext()) {
String nameValue = scanner.next();
String[] parts = nameValue.split("=");
if (parts.length != 2) {
throw new DropboxParseException("Bad query string from Dropbox.");
}
result.put(parts[0], parts[1]);
}
return result;