热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

org.mule.util.IOUtils类的使用及代码示例

本文整理了Java中org.mule.util.IOUtils类的一些代码示例,展示了IOUtils类的具体用法。这些代码示例主要来源于

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

IOUtils介绍

[英]Mule input/output utilities.
[中]Mule输入/输出实用程序。

代码示例

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

/**
* Attempts to load a resource from the file system, from a URL, or from the
* classpath, in that order.
*
* @param resourceName The name of the resource to load
* @param callingClass The Class object of the calling object
* @return an InputStream to the resource or null if resource not found
* @throws java.io.IOException IO error
*/
public static InputStream getResourceAsStream(final String resourceName,
final Class callingClass) throws IOException
{
return getResourceAsStream(resourceName, callingClass, true, true);
}

代码示例来源: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-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

protected String createStringFromInputStream(InputStream input)
{
try
{
return IOUtils.toString(input);
}
finally
{
IOUtils.closeQuietly(input);
}
}

代码示例来源: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

/**
* Attempts to load a resource from the file system, from a URL, or from the
* classpath, in that order.
*
* @param resourceName The name of the resource to load
* @param callingClass The Class object of the calling object
* @return the requested resource as a string
* @throws java.io.IOException IO error
*/
public static String getResourceAsString(final String resourceName, final Class callingClass)
throws IOException
{
try (InputStream is = getResourceAsStream(resourceName, callingClass))
{
if (is != null)
{
return toString(is);
}
else
{
throw new IOException("Unable to load resource " + resourceName);
}
}
}

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

@Override
public String getResourceAsString(String resourceName) throws IOException
{
return IOUtils.getResourceAsString(resourceName, getClass());
}
}

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

InputStream in = IOUtils.getResourceAsStream(file, getClass(), false, false);
if (in == null)
IOUtils.copyLarge(in, baos);
byte[] buffer = baos.toByteArray();

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

private void updateTextFile()
{
Properties props = getStoreAsProperties();
try
{
if (output != null)
{
closeQuietly(output);
}
output = new FileOutputStream(fileStore, false);
props.store(output, StringUtils.EMPTY);
}
catch (IOException e)
{
logger.error(e.getMessage(), e);
}
}

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

try
bytes = IOUtils.toByteArray(input);
IOUtils.closeQuietly(input);

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

/**
* Attempts to load a resource from the file system or from the classpath, in
* that order.
*
* @param resourceName The name of the resource to load
* @param callingClass The Class object of the calling object
* @return an URL to the resource or null if resource not found
*/
public static URL getResourceAsUrl(final String resourceName, final Class callingClass)
{
return getResourceAsUrl(resourceName, callingClass, true, true);
}

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

parts[i] = new CustomStringPart(ds.getName(), IOUtils.toString(ds.getInputStream()), mimeType.getParameter(CHARSET_PARAM_NAME), mimeType.getBaseType());
IOUtils.toByteArray(dh.getInputStream())), dh.getContentType(), null);

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

@Override
public Object doTransform(Object src, String encoding) throws TransformerException
{
try
{
String data;
if (src instanceof byte[])
{
data = new String((byte[]) src, encoding);
}
else if (src instanceof InputStream)
{
data = IOUtils.toString((InputStream)src);
}
else
{
data = (String) src;
}
return XMLEntityCodec.decodeString(data);
}
catch (Exception ex)
{
throw new TransformerException(
CoreMessages.transformFailed(src.getClass().getName(), "XML"),
this, ex);
}
}

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

IOUtils.copyLarge(in, baos);
IOUtils.closeQuietly(in);

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

public void write(MuleEvent event, OutputStream out) throws IOException
{
InputStream is = (InputStream) src;
try
{
IOUtils.copyLarge(is, out);
}
finally
{
is.close();
}
}
};

代码示例来源: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/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.modules/mule-module-management

private void loadLicense(String licenseFile) throws IOException
{
license = IOUtils.getResourceAsString(licenseFile, getClass());
license = StringMessageUtils.getBoilerPlate(license, ' ', 80);
}

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

@Override
public synchronized void dispose()
{
Properties props = getStoreAsProperties();
if (output == null)
{
try
{
output = new FileOutputStream(fileStore, false);
props.store(output, StringUtils.EMPTY);
closeQuietly(output);
}
catch (IOException e)
{
logger.error(e.getMessage(), e);
}
}
else
{
closeQuietly(output);
}
super.dispose();
}

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

@Override
protected Object doTransform(Object src, String encoding) throws TransformerException
{
String string;
if (src instanceof byte[])
{
string = new String((byte[]) src);
}
else if (src instanceof InputStream)
{
InputStream input = (InputStream) src;
try
{
string = IOUtils.toString(input);
}
finally
{
IOUtils.closeQuietly(input);
}
}
else
{
string = (String) src;
}
return append(message, string);
}

推荐阅读
author-avatar
尽做好风水_549_881
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有