com.offbytwo.jenkins.client.util.HttpResponseContentExtractor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jenkins-client Show documentation
Show all versions of jenkins-client Show documentation
A Jenkins API client for Java
package com.offbytwo.jenkins.client.util;
import java.io.IOException;
import java.io.InputStream;
import java.util.Scanner;
import org.apache.http.HttpResponse;
public class HttpResponseContentExtractor {
public String contentAsString(HttpResponse response) throws IOException {
Scanner scanner = new Scanner(contentAsInputStream(response));
scanner.useDelimiter("\\z");
StringBuffer sb = new StringBuffer();
while (scanner.hasNext()) {
sb.append(scanner.next());
}
return sb.toString();
}
public InputStream contentAsInputStream(HttpResponse response) throws IOException {
return response.getEntity().getContent();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy