org.mule.util.IOUtils.copy()方法的使用及代码示例

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

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

IOUtils.copy介绍

[英]Re-implement copy method to allow buffer size to be configured. This won't impact all methods because there is no polymorphism for static methods, but rather just direct use of these two methods.
[中]重新实现复制方法以允许配置缓冲区大小。这不会影响所有方法,因为静态方法没有多态性,而只是直接使用这两种方法。

代码示例

代码示例来源:origin: com.mulesoft.munit/mule-munit-support

public static synchronized void copyStreamToFile(InputStream input, File destination) throws IOException {
  if (destination.exists() && !destination.canWrite()) {
    throw new IOException("Destination file does not exist or is not writeable");
  }
  try {
    FileOutputStream output = new FileOutputStream(destination);
    try {
      IOUtils.copy(input, output);
    } finally {
      IOUtils.closeQuietly(output);
    }
  } finally {
    IOUtils.closeQuietly(input);
  }
}

代码示例来源:origin: org.mule/mule-core

public static synchronized void copyStreamToFile(InputStream input, File destination) throws IOException
{
  if (destination.exists() && !destination.canWrite())
  {
    throw new IOException("Destination file does not exist or is not writeable");
  }
  try
  {
    FileOutputStream output = new FileOutputStream(destination);
    try
    {
      IOUtils.copy(input, output);
    }
    finally
    {
      IOUtils.closeQuietly(output);
    }
  }
  finally
  {
    IOUtils.closeQuietly(input);
  }
}

代码示例来源:origin: org.mule/mule-core

protected String createStringFromInputStream(InputStream input, String outputEncoding)
  throws TransformerException
{
  try
  {
    ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
    IOUtils.copy(input, byteOut);
    return byteOut.toString(outputEncoding);
  }
  catch (IOException e)
  {
    throw new TransformerException(CoreMessages.errorReadingStream(), e);
  }
  finally
  {
    try
    {
      input.close();
    }
    catch (IOException e)
    {
      logger.warn("Could not close stream", e);
    }
  }
}

代码示例来源:origin: org.mule.tools.maven/mule-maven-plugin

@Override
public void filter(ClientRequestContext requestContext, ClientResponseContext responseContext) throws IOException
{
  StringBuilder response = new StringBuilder();
  response.append("HTTP response\n");
  response.append(Integer.toString(responseContext.getStatus())).append(" ").append(responseContext.getStatusInfo().getReasonPhrase()).append("\n");
  appendHeaders(response, responseContext.getHeaders());
  if (responseContext.hasEntity())
  {
    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    IOUtils.copy(responseContext.getEntityStream(), stream);
    byte[] responseBytes = stream.toByteArray();
    response.append(new String(responseBytes));
    response.append("\n");
    responseContext.setEntityStream(new ByteArrayInputStream(responseBytes));
  }
  log.debug(response.toString());
}

代码示例来源:origin: com.mulesoft.munit/mule-munit-support

IOUtils.copy(is, os);
IOUtils.closeQuietly(is);
IOUtils.closeQuietly(os);

代码示例来源:origin: org.mule/mule-core

IOUtils.copy(is, os);
IOUtils.closeQuietly(is);
IOUtils.closeQuietly(os);

代码示例来源:origin: com.mulesoft.munit/mule-munit-support

inputStream = jarFile.getInputStream(entry);
  outputStream = new BufferedOutputStream(new FileOutputStream(file));
  IOUtils.copy(inputStream, outputStream);
} finally {
  IOUtils.closeQuietly(inputStream);

代码示例来源:origin: org.mule/mule-core

IOUtils.copy(inputStream, outputStream);

代码示例来源:origin: org.mule.transports/mule-transport-soap

IOUtils.copy(is, bos);

代码示例来源:origin: org.mule/mule-core

public Object read(InputStream in) throws MuleException
{
  if (inboundTransformer == null)
  {
    throw new IllegalArgumentException(CoreMessages.objectIsNull("inboundTransformer").getMessage());
  }
  if (inboundTransformer.isSourceDataTypeSupported(DataTypeFactory.INPUT_STREAM))
  {
    return inboundTransformer.transform(in);
  }
  else
  {
    try
    {
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      IOUtils.copy(in, baos);
      return inboundTransformer.transform(baos.toByteArray());
    }
    catch (IOException e)
    {
      throw new DefaultMuleException(CoreMessages.failedToReadPayload(), e);
    }
  }
}

代码示例来源:origin: org.mule.modules/mule-module-json

IOUtils.copy(transformerInputs.getInputStream(), jsonWriter, msg.getEncoding());
IOUtils.copy(transformerInputs.getReader(), jsonWriter);

相关文章