org.apache.cxf.helpers.IOUtils.copy()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(5.9k)|赞(0)|评价(0)|浏览(178)

本文整理了Java中org.apache.cxf.helpers.IOUtils.copy()方法的一些代码示例,展示了IOUtils.copy()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IOUtils.copy()方法的具体详情如下:
包路径:org.apache.cxf.helpers.IOUtils
类名称:IOUtils
方法名:copy

IOUtils.copy介绍

[英]Copy at least the specified number of bytes from the input to the output or until the inputstream is finished.
[中]将至少指定数量的字节从输入复制到输出,或直到inputstream完成。

代码示例

代码示例来源:origin: org.apache.cxf/cxf-rt-transports-http

@Override
public int copyFrom(InputStream in) throws IOException {
  if (!written) {
    onFirstWrite();
    written = true;
  }
  if (wrappedStream != null) {
    return IOUtils.copy(in, wrappedStream);
  }
  return IOUtils.copy(in, this, IOUtils.DEFAULT_BUFFER_SIZE);
}

代码示例来源:origin: org.apache.cxf/cxf-rt-transports-http

private void renderStyleSheet(HttpServletRequest request, HttpServletResponse response)
  throws IOException {
  response.setContentType("text/css; charset=UTF-8");
  URL url = this.getClass().getResource("servicelist.css");
  if (url != null) {
    IOUtils.copy(url.openStream(), response.getOutputStream());
  }
}

代码示例来源:origin: opensourceBIM/BIMserver

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");
  }
}

代码示例来源:origin: org.apache.cxf/cxf-rt-frontend-jaxws

if (src.getInputStream() != null) {
  try (ByteArrayOutputStream bos = new ByteArrayOutputStream(2048)) {
    IOUtils.copy(src.getInputStream(), bos, 1024);
    ds = new ByteDataSource(bos.toByteArray(), ct);

代码示例来源:origin: org.apache.cxf/cxf-rt-frontend-jaxws

try {
  InputStream in = ds.getInputStream();
  IOUtils.copy(in, out);
  in.close();
  out.flush();

代码示例来源:origin: apache/cxf

public static void copyAndCloseInput(final Reader input,
                  final Writer output) throws IOException {
  try {
    copy(input, output, DEFAULT_BUFFER_SIZE);
  } finally {
    input.close();
  }
}

代码示例来源:origin: org.apache.cxf/cxf-api

public static void copyAndCloseInput(final Reader input,
    final Writer output, int bufferSize) throws IOException {
  try {
    copy(input, output, bufferSize);
  } finally {
    input.close();
  }
}

代码示例来源:origin: apache/cxf

public static int copyAndCloseInput(final InputStream input,
    final OutputStream output) throws IOException {
  try {
    return copy(input, output);
  } finally {
    input.close();
  }
}

代码示例来源:origin: apache/cxf

public static void copyAndCloseInput(final Reader input,
    final Writer output, int bufferSize) throws IOException {
  try {
    copy(input, output, bufferSize);
  } finally {
    input.close();
  }
}

代码示例来源:origin: org.apache.cxf/cxf-bundle-jaxrs

@Override
public int copyFrom(InputStream in) throws IOException {
  if (!written) {
    onFirstWrite();
    written = true;
  }
  if (wrappedStream != null) {
    return IOUtils.copy(in, wrappedStream);
  }
  return IOUtils.copy(in, this, IOUtils.DEFAULT_BUFFER_SIZE);
}

代码示例来源:origin: apache/cxf

@Override
public int copyFrom(InputStream in) throws IOException {
  if (!written) {
    onFirstWrite();
    written = true;
  }
  if (wrappedStream != null) {
    return IOUtils.copy(in, wrappedStream);
  }
  return IOUtils.copy(in, this, IOUtils.DEFAULT_BUFFER_SIZE);
}

代码示例来源:origin: apache/cxf

public static byte[] readBytesFromStream(InputStream in) throws IOException {
    int i = in.available();
    if (i < DEFAULT_BUFFER_SIZE) {
      i = DEFAULT_BUFFER_SIZE;
    }
    try (ByteArrayOutputStream bos = new ByteArrayOutputStream(i)) {
      copy(in, bos);
      return bos.toByteArray();
    } finally {
      in.close();
    }
  }
}

代码示例来源:origin: org.apache.cxf/cxf-bundle-jaxrs

private void renderStyleSheet(HttpServletRequest request, HttpServletResponse response)
  throws IOException {
  response.setContentType("text/css; charset=UTF-8");
  URL url = this.getClass().getResource("servicelist.css");
  if (url != null) {
    IOUtils.copy(url.openStream(), response.getOutputStream());
  }
}

代码示例来源:origin: apache/cxf

private void renderStyleSheet(HttpServletRequest request, HttpServletResponse response)
  throws IOException {
  response.setContentType("text/css; charset=UTF-8");
  URL url = this.getClass().getResource("servicelist.css");
  if (url != null) {
    IOUtils.copy(url.openStream(), response.getOutputStream());
  }
}

代码示例来源:origin: apache/cxf

public static String readBody(InputStream is, String encoding) {
  try {
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    IOUtils.copy(is, bos, 1024);
    return new String(bos.toByteArray(), encoding);
  } catch (Exception ex) {
    throw ExceptionUtils.toInternalServerErrorException(ex, null);
  }
}

代码示例来源:origin: org.apache.cxf/cxf-rt-transports-http

if (in != null) {
  CachedOutputStream cos = new CachedOutputStream();
  IOUtils.copy(in, cos);
  inMessage.setContent(InputStream.class, cos.getInputStream());

代码示例来源:origin: apache/cxf

protected void writeJws(JwsJsonProducer p, OutputStream os)
  throws IOException {
  byte[] bytes = StringUtils.toBytesUTF8(p.getJwsJsonSignedDocument());
  IOUtils.copy(new ByteArrayInputStream(bytes), os);
}

代码示例来源:origin: apache/cxf

protected void writeJws(JwsJsonProducer p, OutputStream os)
  throws IOException {
  byte[] bytes = StringUtils.toBytesUTF8(p.getJwsJsonSignedDocument());
  IOUtils.copy(new ByteArrayInputStream(bytes), os);
}

代码示例来源:origin: org.apache.cxf/cxf-rt-transports-http-jetty

@Override
public int copyFrom(InputStream in) throws IOException {
  if (written) {
    return IOUtils.copy(in, out);
  }
  CountingInputStream c = new CountingInputStream(in);
  if (!sendContent(InputStream.class, c)
    && !sendContent(Object.class, c)) {
    IOUtils.copy(c, out);
  }
  return c.getCount();
}
public void write(int b) throws IOException {

代码示例来源:origin: apache/cxf

public void onMessage(Message message) {
    LoadingByteArrayOutputStream bout = new LoadingByteArrayOutputStream();
    try {
      IOUtils.copy(message.getContent(InputStream.class), bout);
      message.getExchange().put(InputStream.class, bout.createInputStream());
      c.close(message);
    } catch (IOException e) {
      //ignore
    }
  }
});

相关文章