本文整理汇总了Java中org.apache.cxf.helpers.IOUtils.toString方法的典型用法代码示例。如果您正苦于以下问题:Java IOUtils.toString方法的具体用法?Java IOUtils.toString怎么用?Java IOUtils.toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.cxf.helpers.IOUtils
的用法示例。
在下文中一共展示了IOUtils.toString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doPost
import org.apache.cxf.helpers.IOUtils; //导入方法依赖的package包/类
String doPost(String api, Prameters prams) {
WebClient wc = WebClient.create(api);
Form form = new Form();
form.param(ACCESS_TOKEN, access_token());
String[] keys = prams.keys;
for(int i = 0 ; i < keys.length ; i ++){
form.param(keys[i], prams.value(i).toString());
}
Response resp = wc.form(form);
String result = "";
try {
result = IOUtils.toString((InputStream) resp.getEntity());
} catch (IOException e) {
throw new ParseResultException(e);
}
handleResponse(resp, wc);
return result;
}
示例2: doPostOauth2
import org.apache.cxf.helpers.IOUtils; //导入方法依赖的package包/类
String doPostOauth2(String api, Prameters prams) {
WebClient wc = WebClient.create(api);
Form form = new Form();
String[] keys = prams.keys;
for(int i = 0 ; i < keys.length ; i ++){
form.param(keys[i], prams.value(i).toString());
}
Response resp = wc.form(form);
String result = "";
try {
result = IOUtils.toString((InputStream) resp.getEntity());
} catch (IOException e) {
throw new ParseResultException(e);
}
handleResponse(resp, wc);
return result;
}
示例3: doGet
import org.apache.cxf.helpers.IOUtils; //导入方法依赖的package包/类
String doGet(String api, Prameters prams){
WebClient wc = WebClient.create(api);
wc.query(ACCESS_TOKEN, access_token());
String[] keys = prams.keys;
for(int i = 0 ; i < keys.length ; i ++){
wc.query(keys[i], prams.value(i));
}
Response resp = wc.get();
String result = "";
try {
result = IOUtils.toString((InputStream) resp.getEntity());
} catch (IOException e) {
throw new ParseResultException(e);
}
handleResponse(resp, wc);
return result;
}
示例4: deleteDocstoreRecord
import org.apache.cxf.helpers.IOUtils; //导入方法依赖的package包/类
public String deleteDocstoreRecord(String docType, String uuid) throws IOException {
String docstoreRestfulURL = SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(
OLEConstants.OLE_DOCSTORE_RESTFUL_URL);
docstoreRestfulURL = docstoreRestfulURL.concat("/") + uuid;
HttpClient httpClient = new HttpClient();
DeleteMethod deleteMethod = new DeleteMethod(docstoreRestfulURL);
NameValuePair nvp1 = new NameValuePair(OLEConstants.IDENTIFIER_TYPE, OLEConstants.UUID);
NameValuePair nvp2 = new NameValuePair(OLEConstants.OPERATION, OLEConstants.DELETE);
NameValuePair category = new NameValuePair(OLEConstants.DOC_CATEGORY, OLEConstants.BIB_CATEGORY_WORK);
NameValuePair type = new NameValuePair(OLEConstants.DOC_TYPE, docType);
NameValuePair format = new NameValuePair(OLEConstants.DOC_FORMAT, OLEConstants.BIB_FORMAT_OLEML);
deleteMethod.setQueryString(new NameValuePair[]{nvp1, nvp2, category, type, format});
int statusCode = httpClient.executeMethod(deleteMethod);
InputStream inputStream = deleteMethod.getResponseBodyAsStream();
return IOUtils.toString(inputStream);
}
示例5: extract
import org.apache.cxf.helpers.IOUtils; //导入方法依赖的package包/类
protected SAML2ReceivedResponseTO extract(
final String spEntityID,
final String urlContext,
final String clientAddress,
final InputStream response) throws IOException {
String strForm = IOUtils.toString(response);
MultivaluedMap<String, String> params = JAXRSUtils.getStructuredParams(strForm, "&", false, false);
String samlResponse = params.getFirst(SSOConstants.SAML_RESPONSE);
if (StringUtils.isNotBlank(samlResponse)) {
samlResponse = URLDecoder.decode(samlResponse, StandardCharsets.UTF_8.name());
LOG.debug("Received SAML Response: {}", samlResponse);
}
String relayState = params.getFirst(SSOConstants.RELAY_STATE);
LOG.debug("Received Relay State: {}", relayState);
SAML2ReceivedResponseTO receivedResponseTO = new SAML2ReceivedResponseTO();
receivedResponseTO.setSpEntityID(spEntityID);
receivedResponseTO.setUrlContext(urlContext);
receivedResponseTO.setSamlResponse(samlResponse);
receivedResponseTO.setRelayState(relayState);
return receivedResponseTO;
}
示例6: testgetTechnicalComponents
import org.apache.cxf.helpers.IOUtils; //导入方法依赖的package包/类
@Test
public void testgetTechnicalComponents() throws Exception {
logger.info("======= Running test testgetTechnicalComponents ===========");
WebClient client = WebClient.create(endpointUrl
+ "?serviceClassName=com.liferay.infinity.service.InfrastructureServiceUtil&serviceMethodName=getTechnicalComponents");
Response r = client.accept("text/plain").get();
assertEquals(Response.Status.OK.getStatusCode(), r.getStatus());
String value = IOUtils.toString((InputStream) r.getEntity());
assertEquals(
"[{\"id\":\"212\",\"other\":null,\"name\":null,\"value\":\"Application Service Delivery\",\"javaClass\":\"org.infinity.model.ValueID\"}," +
"{\"id\":\"242\",\"other\":null,\"name\":null,\"value\":\"Backbone Network\",\"javaClass\":\"org.infinity.model.ValueID\"}," +
"{\"id\":\"277\",\"other\":null,\"name\":null,\"value\":\"Cloud Network\",\"javaClass\":\"org.infinity.model.ValueID\"}," +
"{\"id\":\"194\",\"other\":null,\"name\":null,\"value\":\"Customers Device\",\"javaClass\":\"org.infinity.model.ValueID\"}," +
"{\"id\":\"204\",\"other\":null,\"name\":null,\"value\":\"Data Context Management\",\"javaClass\":\"org.infinity.model.ValueID\"}," +
"{\"id\":\"218\",\"other\":null,\"name\":null,\"value\":\"Mobile Network\",\"javaClass\":\"org.infinity.model.ValueID\"}," +
"{\"id\":\"2377\",\"other\":null,\"name\":null,\"value\":\"Satellite Network\",\"javaClass\":\"org.infinity.model.ValueID\"}," +
"{\"id\":\"176\",\"other\":null,\"name\":null,\"value\":\"Sensor Network\",\"javaClass\":\"org.infinity.model.ValueID\"}," +
"{\"id\":\"230\",\"other\":null,\"name\":null,\"value\":\"WIFI Network\",\"javaClass\":\"org.infinity.model.ValueID\"}," +
"{\"id\":\"264\",\"other\":null,\"name\":null,\"value\":\"Wired Access Network\",\"javaClass\":\"org.infinity.model.ValueID\"}]",
value);
}
示例7: inputStream2String
import org.apache.cxf.helpers.IOUtils; //导入方法依赖的package包/类
/**
*
* 输入流转化为string
*
* @param is
* @return
* @throws IOException
* @since eSDK Solution Platform SSO V1R3C10
*/
private String inputStream2String(InputStream is)
throws IOException
{
if (null == is)
{
return "";
}
return IOUtils.toString(is, "UTF-8");
}
示例8: testShouldNotFailWhenThereAreNonASCIICharactersOnHeaders
import org.apache.cxf.helpers.IOUtils; //导入方法依赖的package包/类
@Test
public void testShouldNotFailWhenThereAreNonASCIICharactersOnHeaders() throws Exception {
// given
String folder = tempFolder.newFolder().toString();
String url1 = "http://a.com";
Map<String, List<String>> headers = new HashMap<>();
Character invalidChar = new Character((char) 0x80);
String headerValue = "inline; filename=\"Invalid_" + invalidChar + "\"";
headers.put("Content-Disposition", asList(headerValue));
Page target1 = new Page(new URL(url1), html, headers);
WarcTargetRepository repository = new WarcTargetRepository(folder);
// when
repository.insert(target1);
repository.close();
RepositoryIterator respositoryIterator = repository.iterator();
// then
assertTrue(respositoryIterator.hasNext());
WARCRecord record = respositoryIterator.next();
assertThat(record.getHeader().getUrl(), is(url1));
String recordData = IOUtils.toString(record);
assertThat(recordData, containsString(html));
assertThat(recordData, containsString(headerValue));
assertFalse(respositoryIterator.hasNext());
}
示例9: getMetadata
import org.apache.cxf.helpers.IOUtils; //导入方法依赖的package包/类
@GET
@Path("/$metadata")
@Produces("application/xml")
public String getMetadata() {
try {
final String src = File.separatorChar + "v4" + File.separatorChar + "metadata.xml";
return IOUtils.toString(getClass().getResourceAsStream(src), "UTF-8");
} catch (Exception e) {
LOG.error("Failure retrieving metadata information", e);
return "";
}
}
示例10: getMetadata
import org.apache.cxf.helpers.IOUtils; //导入方法依赖的package包/类
@GET
@Path("/$metadata")
@Produces("application/xml")
public String getMetadata() {
try {
final String src = File.separatorChar + "v3" + File.separatorChar + "metadata.xml";
return IOUtils.toString(getClass().getResourceAsStream(src), "UTF-8");
} catch (Exception e) {
LOG.error("Failure retrieving metadata information", e);
return "";
}
}
示例11: testPing
import org.apache.cxf.helpers.IOUtils; //导入方法依赖的package包/类
@Test
public void testPing() throws Exception {
WebClient client = WebClient.create(endpointUrl + "/hello/echo/SierraTangoNevada");
Response r = client.accept("text/plain").get();
assertEquals(Response.Status.OK.getStatusCode(), r.getStatus());
String value = IOUtils.toString((InputStream)r.getEntity());
assertEquals("SierraTangoNevada", value);
}
示例12: testGetClassificationsShortUrl
import org.apache.cxf.helpers.IOUtils; //导入方法依赖的package包/类
@Test
public void testGetClassificationsShortUrl() throws Exception {
WebClient client = WebClient.create(endpointUrl + "/classifications/yugioh/Astral");
Response r = client.accept("application/json").get();
assertEquals(Response.Status.OK.getStatusCode(), r.getStatus());
String value = IOUtils.toString((InputStream) r.getEntity());
assertNotNull(value);
// TODO: deserialize and read
}
示例13: testGetClassificationsFullUrl
import org.apache.cxf.helpers.IOUtils; //导入方法依赖的package包/类
@Test
public void testGetClassificationsFullUrl() throws Exception {
WebClient client = WebClient.create(endpointUrl + "/classifications/http://yugioh.wikia.com/api.php/Astral");
Response r = client.accept("application/json").get();
assertEquals(Response.Status.OK.getStatusCode(), r.getStatus());
String value = IOUtils.toString((InputStream) r.getEntity());
assertNotNull(value);
// TODO: deserialize and read
}
示例14: readFrom
import org.apache.cxf.helpers.IOUtils; //导入方法依赖的package包/类
public Object readFrom(Class<Object> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException {
String s=IOUtils.toString(entityStream);
return JSON.parseObject(s, genericType);
}
示例15: getResource
import org.apache.cxf.helpers.IOUtils; //导入方法依赖的package包/类
/**
* @param stream an input stream we can read the file from (this will close it for you)
*/
protected String getResource(InputStream stream) throws Exception {
return IOUtils.toString(stream, "UTF-8");
}