当前位置: 首页>>代码示例>>Java>>正文


Java IOUtils类代码示例

本文整理汇总了Java中org.apache.cxf.helpers.IOUtils的典型用法代码示例。如果您正苦于以下问题:Java IOUtils类的具体用法?Java IOUtils怎么用?Java IOUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


IOUtils类属于org.apache.cxf.helpers包,在下文中一共展示了IOUtils类的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;
}
 
开发者ID:kylinsoong,项目名称:weibo4j,代码行数:19,代码来源:Weibo.java

示例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;
}
 
开发者ID:kylinsoong,项目名称:weibo4j,代码行数:18,代码来源:Weibo.java

示例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;
}
 
开发者ID:kylinsoong,项目名称:weibo4j,代码行数:18,代码来源:Weibo.java

示例4: decryptContent

import org.apache.cxf.helpers.IOUtils; //导入依赖的package包/类
public static void decryptContent( SecurityManager securityManager, Message message, String hostIdSource,
                                   String hostIdTarget )
{

    InputStream is = message.getContent( InputStream.class );

    CachedOutputStream os = new CachedOutputStream();

    LOG.debug( String.format( "Decrypting IDs: %s -> %s", hostIdSource, hostIdTarget ) );
    try
    {
        int copied = IOUtils.copyAndCloseInput( is, os );
        os.flush();

        byte[] data = copied > 0 ? decryptData( securityManager, hostIdSource, os.getBytes() ) : null;
        org.apache.commons.io.IOUtils.closeQuietly( os );

        if ( !ArrayUtils.isEmpty( data ) )
        {
            LOG.debug( String.format( "Decrypted payload: \"%s\"", new String( data ) ) );
            message.setContent( InputStream.class, new ByteArrayInputStream( data ) );
        }
        else
        {
            LOG.debug( "Decrypted data is NULL!!!" );
        }
    }
    catch ( Exception e )
    {
        LOG.error( "Error decrypting content", e );
    }
}
 
开发者ID:subutai-io,项目名称:base,代码行数:33,代码来源:MessageContentUtil.java

示例5: process

import org.apache.cxf.helpers.IOUtils; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void process(Exchange exchange) throws Exception {
    CxfPayload<SoapHeader> in = exchange.getIn().getBody(CxfPayload.class);
    
    // verify request
    Assert.assertEquals(1, in.getBody().size());
    
    DataHandler dr = exchange.getIn().getAttachment(MtomTestHelper.REQ_PHOTO_CID);
    Assert.assertEquals("application/octet-stream", dr.getContentType());
    MtomTestHelper.assertEquals(MtomTestHelper.REQ_PHOTO_DATA, IOUtils.readBytesFromStream(dr.getInputStream()));
       
    dr = exchange.getIn().getAttachment(MtomTestHelper.REQ_IMAGE_CID);
    Assert.assertEquals("image/jpeg", dr.getContentType());
    MtomTestHelper.assertEquals(MtomTestHelper.requestJpeg, IOUtils.readBytesFromStream(dr.getInputStream()));

    // create response
    List<Source> elements = new ArrayList<Source>();
    elements.add(new DOMSource(StaxUtils.read(new StringReader(MtomTestHelper.MTOM_DISABLED_RESP_MESSAGE)).getDocumentElement()));
    CxfPayload<SoapHeader> body = new CxfPayload<SoapHeader>(new ArrayList<SoapHeader>(),
        elements, null);
    exchange.getOut().setBody(body);
    exchange.getOut().addAttachment(MtomTestHelper.RESP_PHOTO_CID, 
        new DataHandler(new ByteArrayDataSource(MtomTestHelper.RESP_PHOTO_DATA, "application/octet-stream")));

    exchange.getOut().addAttachment(MtomTestHelper.RESP_IMAGE_CID, 
        new DataHandler(new ByteArrayDataSource(MtomTestHelper.responseJpeg, "image/jpeg")));

}
 
开发者ID:HydAu,项目名称:Camel,代码行数:29,代码来源:CxfMtomDisabledConsumerPayloadModeTest.java

示例6: check

import org.apache.cxf.helpers.IOUtils; //导入依赖的package包/类
@Override
public SOAPResponse check(SOAPRequest input) throws ServerException {

	Pipeline pipeline = new Pipeline();
	byte[] annotatedFile;
	try {
		Input ltinput = new Input();
		ltinput.setData(input.getData().getInputStream());
		ltinput.setEncoding(input.getEncoding());
		ltinput.setSrcLocale(input.getSource());
		ltinput.setTgtLocale(input.getTarget());
		Output output = pipeline.check(ltinput);
		SOAPResponse response = new SOAPResponse();
		annotatedFile = IOUtils.readBytesFromStream(output.getData());
		DataSource responseFile = new ByteArrayDataSource(annotatedFile,
				ITSProcessorImpl.OUTPUT_MIME_TYPE);
		DataHandler handler = new DataHandler(responseFile);
		response.setData(handler);
		response.setEncoding(output.getEncoding());
		return response;
	} catch (Exception e) {
		throw new ServerException(e);
	}

}
 
开发者ID:SAP,项目名称:Lapwing,代码行数:26,代码来源:ITSProcessorImpl.java

示例7: search

import org.apache.cxf.helpers.IOUtils; //导入依赖的package包/类
public static Response search(Request request) throws IOException {
    CloseableHttpClient client = HttpClients.createDefault();
    HttpGet httpGet = new HttpGet("http://" + loadBalance.getServer() + "/solr/" + dataset + "/select?" + request.toEncodedQueryString());
    CloseableHttpResponse httpResponse = null;
    try {
        httpResponse = client.execute(httpGet);
        String content = null;
        if (HttpStatus.SC_OK == httpResponse.getStatusLine().getStatusCode()) {
            HttpEntity entity = httpResponse.getEntity();
            content = IOUtils.readStringFromStream(entity.getContent());
        }
        return new Response(httpResponse.getStatusLine().getStatusCode(), content);

    } finally {
        if (httpResponse != null) {
            httpResponse.close();
        }
        if (client != null) {
            client.close();
        }
    }
}
 
开发者ID:yeleid,项目名称:archive,代码行数:23,代码来源:SearchEngine.java

示例8: logReader

import org.apache.cxf.helpers.IOUtils; //导入依赖的package包/类
protected void logReader(Message message, Reader reader, LoggingMessage buffer) {
    try {
        CachedWriter writer = new CachedWriter();
        IOUtils.copyAndCloseInput(reader, writer);
        message.setContent(Reader.class, writer.getReader());
        
        if (writer.getTempFile() != null) {
            //large thing on disk...
            buffer.getMessage().append("\nMessage (saved to tmp file):\n");
            buffer.getMessage().append("Filename: " + writer.getTempFile().getAbsolutePath() + "\n");
        }
        if (writer.size() > limit && limit != -1) {
            buffer.getMessage().append("(message truncated to " + limit + " bytes)\n");
        }
        writer.writeCacheTo(buffer.getPayload(), limit);
    } catch (Exception e) {
        throw new Fault(e);
    }
}
 
开发者ID:GeeQuery,项目名称:cxf-plus,代码行数:20,代码来源:LoggingInInterceptor.java

示例9: 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);
}
 
开发者ID:VU-libtech,项目名称:OLE-INST,代码行数:17,代码来源:OleDocstoreHelperServiceImpl.java

示例10: 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;
}
 
开发者ID:apache,项目名称:syncope,代码行数:26,代码来源:AbstractSAML2SPServlet.java

示例11: 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);
}
 
开发者ID:SmartInfrastructures,项目名称:xipi,代码行数:22,代码来源:TransformationTest.java

示例12: serveStaticContent

import org.apache.cxf.helpers.IOUtils; //导入依赖的package包/类
protected void serveStaticContent(HttpServletRequest request, HttpServletResponse response, String pathInfo) throws ServletException {
	InputStream is = super.getServletContext().getResourceAsStream(pathInfo);
	if (is == null) {
		throw new ServletException("Static resource " + pathInfo + " is not available");
	}
	try {
		int ind = pathInfo.lastIndexOf(".");
		if (ind != -1 && ind < pathInfo.length()) {
			String type = STATIC_CONTENT_TYPES.get(pathInfo.substring(ind + 1));
			if (type != null) {
				response.setContentType(type);
			}
		}

		ServletOutputStream os = response.getOutputStream();
		IOUtils.copy(is, os);
		os.flush();
	} catch (IOException ex) {
		throw new ServletException("Static resource " + pathInfo + " can not be written to the output stream");
	}
}
 
开发者ID:opensourceBIM,项目名称:BIMserver,代码行数:22,代码来源:GenericWebServiceServlet.java

示例13: getFoo

import org.apache.cxf.helpers.IOUtils; //导入依赖的package包/类
@GET
@Timed
public String getFoo() {

    ObjectFactory of = new ObjectFactory();
    Hello h = of.createHello();
    h.setTitle("Hello");
    h.setBinary(new DataHandler(new ByteArrayDataSource("test".getBytes(), "text/plain")));

    HelloResponse hr = mtomServiceClient.hello(h);

    try {
        return "Hello response: " + hr.getTitle() + ", " +
                IOUtils.readStringFromStream(hr.getBinary().getInputStream());
    }
    catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:roskart,项目名称:dropwizard-jaxws,代码行数:20,代码来源:AccessMtomServiceResource.java

示例14: executeMethodGET

import org.apache.cxf.helpers.IOUtils; //导入依赖的package包/类
private SimpleHttpResponse executeMethodGET(HttpURLConnection urlConnection) throws IOException, InvalidResponseException {
	SimpleHttpResponse httpResponse = new SimpleHttpResponse(urlConnection.getURL().toString(), urlConnection.getResponseCode(),
			urlConnection.getResponseMessage());
	httpResponse.setContentType(urlConnection.getContentType());
	httpResponse.setContent(IOUtils.toString(urlConnection.getInputStream()));
	logResponse(httpResponse);
	validateResponse(httpResponse);
	return httpResponse;
}
 
开发者ID:SAP,项目名称:cloud-c4c-ticket-duplicate-finder-ext,代码行数:10,代码来源:HTTPConnector.java

示例15: entityToString

import org.apache.cxf.helpers.IOUtils; //导入依赖的package包/类
private String entityToString(Object entity) {
    try {
        if (entity instanceof InputStream) {
            return IOUtils.readStringFromStream((InputStream) entity);
        }
        if (entity == null) {
            return "null";
        }
        return entity.toString();
    } catch (IOException e) {
        return "Could not read entity: " + e;
    }
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:14,代码来源:ForgeTestSupport.java


注:本文中的org.apache.cxf.helpers.IOUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。