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

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

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

IOUtils.toByteArray介绍

[英]This method wraps org.apache.commons.io.IOUtils' toByteArray(InputStream) method but catches any IOException and wraps it into a RuntimeException.
[中]这个方法包装了组织。阿帕奇。平民木卫一。IOUtils'toByteArray(InputStream)方法,但捕获任何IOException并将其包装为RuntimeException。

代码示例

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

public CachedResource(Reader reader, String encoding) throws IOException
{
  this(IOUtils.toByteArray(reader, encoding), DEFAULT_DESCRIPTION);
}

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

public CachedResource(Reader reader, String encoding) throws IOException
{
  this(IOUtils.toByteArray(reader, encoding), DEFAULT_DESCRIPTION);
}

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

public CachedServletInputStream(ServletInputStream servletInputStream)
{
  byte[] bytes = IOUtils.toByteArray(servletInputStream);
  this.cachedStream = new ByteArrayInputStream(bytes);
}

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

public byte[] getBodyBytes() throws IOException
{
  InputStream in = getBody();
  if (in != null)
  {
    return IOUtils.toByteArray(in);
  }
  else
  {
    return null;
  }
}

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

@Override
protected Object extractPayload(Object transportMessage, String encoding) throws Exception
{
  InputStream inputStream = convertToInputStream(transportMessage);
  byte[] payload = IOUtils.toByteArray(inputStream);
  inputStream.close();
  return payload;
}

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

protected ResourceReleaser createResourceReleaserInstance()
{
  InputStream classStream = null;
  try
  {
    classStream = this.getClass().getResourceAsStream(resourceReleaserClassLocation);
    byte[] classBytes = IOUtils.toByteArray(classStream);
    classStream.close();
    Class clazz = this.defineClass(null, classBytes, 0, classBytes.length);
    return (ResourceReleaser) clazz.newInstance();
  }
  catch (Exception e)
  {
    throw new RuntimeException("Can not create resource releaser instance from resource: " + resourceReleaserClassLocation, e);
  }
  finally
  {
    closeQuietly(classStream);
  }
}

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

private HttpPartDataSource(HttpPart part)
{
  try
  {
    this.part = part;
    this.content = IOUtils.toByteArray(part.getInputStream());
  }
  catch (IOException e)
  {
    throw new MuleRuntimeException(e);
  }
}

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

public Object getObject() throws Exception
{
  if(data!=null)
  {
    return data;
  }
  if(file!=null)
  {
    if(binary)
    {
      data = IOUtils.toByteArray(IOUtils.getResourceAsStream(file, getClass()));
    }
    else
    {
      data = IOUtils.getResourceAsString(file, getClass());
    }
  }
  else if(ref!=null)
  {
    data = context.getBean(ref);
  }
  if(data==null)
  {
    throw new IllegalArgumentException("Data is null was not found");
  }
  return data;
}

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

try
  buf = IOUtils.toByteArray(input);

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

protected Object extractPayloadFromHttpRequest(HttpRequest httpRequest) throws IOException
{
  Object body = httpRequest.getBody();
  // If http method is GET we use the request uri as the payload.
  if (body == null)
  {
    body = httpRequest.getRequestLine().getUri();
  }
  else
  {
    // If we are running async we need to read stream into a byte[].
    // Passing along the InputStream doesn't work because the
    // HttpConnection gets closed and closes the InputStream, often
    // before it can be read.
    if (!exchangePattern.hasResponse())
    {
      log.debug("Reading HTTP POST InputStream into byte[] for asynchronous messaging.");
      body = IOUtils.toByteArray((InputStream) body);
    }
  }
  return body;
}

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

@Override
public void setParameterValue(PreparedStatement statement, int index, Object value) throws SQLException
{
  if (value != null && !(value instanceof Blob))
  {
    Blob blob = statement.getConnection().createBlob();
    if (value instanceof byte[])
    {
      blob.setBytes(1, (byte[]) value);
    }
    else if (value instanceof InputStream)
    {
      blob.setBytes(1,  IOUtils.toByteArray((InputStream) value));
    }
    else
    {
      throw new IllegalArgumentException(createUnsupportedTypeErrorMessage(value));
    }
    value = blob;
  }
  super.setParameterValue(statement, index, value);
}

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

public static Collection<HttpPart> createFrom(Map<String, DataHandler> parts) throws IOException
{
  final ArrayList<HttpPart> httpParts = new ArrayList<>(parts.size());
  for (String partName : parts.keySet())
  {
    final DataHandler dataHandlerPart = parts.get(partName);
    if (dataHandlerPart.getDataSource() instanceof HttpPartDataSource)
    {
      httpParts.add(((HttpPartDataSource) dataHandlerPart.getDataSource()).getPart());
    }
    else
    {
      byte[] data = IOUtils.toByteArray(dataHandlerPart.getInputStream());
      String fileName = null;
      if (dataHandlerPart.getDataSource() instanceof FileDataSource || dataHandlerPart.getDataSource() instanceof ByteArrayDataSource)
      {
        fileName = dataHandlerPart.getDataSource().getName();
      }
      httpParts.add(new HttpPart(partName, fileName, data, dataHandlerPart.getContentType(), data.length));
    }
  }
  return httpParts;
}

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

try
  bytes = IOUtils.toByteArray(input);

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

private static Resource[] convert(ConfigResource[] resources)
{
  Resource[] configResources = new Resource[resources.length];
  for (int i = 0; i < resources.length; i++)
  {
    ConfigResource resource = resources[i];
    if (resource.getUrl() != null)
    {
      configResources[i] = new UrlResource(resource.getUrl());
    }
    else
    {
      try
      {
        configResources[i] = new ByteArrayResource(IOUtils.toByteArray(resource.getInputStream()), resource.getResourceName());
      }
      catch (IOException e)
      {
        throw new RuntimeException(e);
      }
    }
  }
  return configResources;
}

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

if (result.getPayload() instanceof InputStream)
  byte[] b = IOUtils.toByteArray((InputStream)result.getPayload());
  if(b.length==0) return null;
  ByteArrayInputStream in = new ByteArrayInputStream(b);

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

final byte[] partContent = IOUtils.toByteArray(part.getInputStream());
String rootContentId = getContentTypeParameter(contentType, START_PARAMETER);

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

IOUtils.toByteArray(dh.getInputStream())), dh.getContentType(), null);

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

byte[] content = IOUtils.toByteArray(part.getInputStream());
byteArrayPart = new ByteArrayPart(part.getName(), content, part.getContentType(), null, part.getFileName(), contentId, encoding);

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

ByteArrayHttpEntity byteArrayHttpEntity = new ByteArrayHttpEntity(IOUtils.toByteArray(((InputStream) payload)));
setupContentLengthEncoding(httpResponseHeaderBuilder, byteArrayHttpEntity.getContent().length);
httpEntity = byteArrayHttpEntity;

相关文章