use of org.apache.cxf.io.CachedOutputStream in project camel by apache.
the class CxfUtils method getStringFromInputStream.
public static String getStringFromInputStream(InputStream in) throws Exception {
CachedOutputStream bos = new CachedOutputStream();
IOUtils.copy(in, bos);
in.close();
bos.close();
return bos.getOut().toString();
}
use of org.apache.cxf.io.CachedOutputStream in project cxf by apache.
the class JAXRSAtomBookTest method copyIn.
private InputStream copyIn(InputStream in) throws Exception {
try (CachedOutputStream bos = new CachedOutputStream()) {
IOUtils.copyAndCloseInput(in, bos);
in = bos.getInputStream();
bos.close();
return in;
}
}
use of org.apache.cxf.io.CachedOutputStream in project cxf by apache.
the class EngineLifecycleTest method getTestHtml.
private void getTestHtml() throws Exception {
CachedOutputStream response = null;
for (int i = 0; i < 10; i++) {
try {
HttpURLConnection httpConnection = getHttpConnection("http://localhost:" + PORT2 + "/test.html");
httpConnection.connect();
InputStream in = httpConnection.getInputStream();
assertNotNull(in);
response = new CachedOutputStream();
IOUtils.copy(in, response);
in.close();
response.close();
break;
} catch (Exception ex) {
response = null;
Thread.sleep(2 * 1000);
}
}
assertNotNull("Test doc can not be read", response);
FileInputStream htmlFile = new FileInputStream("target/test-classes/org/apache/cxf/systest/http_jetty/test.html");
CachedOutputStream html = new CachedOutputStream();
IOUtils.copy(htmlFile, html);
htmlFile.close();
html.close();
assertEquals("Can't get the right test html", html.toString(), response.toString());
}
use of org.apache.cxf.io.CachedOutputStream in project carbon-business-process by wso2.
the class Utils method getAttachmentStream.
public static OutputStream getAttachmentStream(InputStream inputStream) throws IOException {
if (inputStream != null) {
CachedOutputStream cachedOutputStream = new CachedOutputStream();
IOUtils.copy(inputStream, cachedOutputStream);
cachedOutputStream.close();
return cachedOutputStream.getOut();
}
return null;
}
use of org.apache.cxf.io.CachedOutputStream in project tomee by apache.
the class AttachmentDataSource method cache.
public void cache(Message message) throws IOException {
if (cache == null) {
cache = new CachedOutputStream();
AttachmentUtil.setStreamedAttachmentProperties(message, cache);
try {
IOUtils.copyAndCloseInput(ins, cache);
cache.lockOutputStream();
if (delegate != null) {
delegate.setInputStream(cache.getInputStream());
}
} catch (CacheSizeExceededException | IOException cee) {
cache.close();
cache = null;
throw cee;
} finally {
ins = null;
}
}
}
Aggregations