热门标签 | 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);
}

推荐阅读
  • 本文整理了Java中org.apache.solr.common.SolrDocument.setField()方法的一些代码示例,展示了SolrDocum ... [详细]
  • 本文整理了Java中java.lang.NoSuchMethodError.getMessage()方法的一些代码示例,展示了NoSuchMethodErr ... [详细]
  • 开发笔记:加密&json&StringIO模块&BytesIO模块
    篇首语:本文由编程笔记#小编为大家整理,主要介绍了加密&json&StringIO模块&BytesIO模块相关的知识,希望对你有一定的参考价值。一、加密加密 ... [详细]
  • 目录实现效果:实现环境实现方法一:基本思路主要代码JavaScript代码总结方法二主要代码总结方法三基本思路主要代码JavaScriptHTML总结实 ... [详细]
  • Java容器中的compareto方法排序原理解析
    本文从源码解析Java容器中的compareto方法的排序原理,讲解了在使用数组存储数据时的限制以及存储效率的问题。同时提到了Redis的五大数据结构和list、set等知识点,回忆了作者大学时代的Java学习经历。文章以作者做的思维导图作为目录,展示了整个讲解过程。 ... [详细]
  • 本文讨论了一个关于cuowu类的问题,作者在使用cuowu类时遇到了错误提示和使用AdjustmentListener的问题。文章提供了16个解决方案,并给出了两个可能导致错误的原因。 ... [详细]
  • Java学习笔记之面向对象编程(OOP)
    本文介绍了Java学习笔记中的面向对象编程(OOP)内容,包括OOP的三大特性(封装、继承、多态)和五大原则(单一职责原则、开放封闭原则、里式替换原则、依赖倒置原则)。通过学习OOP,可以提高代码复用性、拓展性和安全性。 ... [详细]
  • Java中包装类的设计原因以及操作方法
    本文主要介绍了Java中设计包装类的原因以及操作方法。在Java中,除了对象类型,还有八大基本类型,为了将基本类型转换成对象,Java引入了包装类。文章通过介绍包装类的定义和实现,解答了为什么需要包装类的问题,并提供了简单易用的操作方法。通过本文的学习,读者可以更好地理解和应用Java中的包装类。 ... [详细]
  • 本文介绍了Swing组件的用法,重点讲解了图标接口的定义和创建方法。图标接口用来将图标与各种组件相关联,可以是简单的绘画或使用磁盘上的GIF格式图像。文章详细介绍了图标接口的属性和绘制方法,并给出了一个菱形图标的实现示例。该示例可以配置图标的尺寸、颜色和填充状态。 ... [详细]
  • 本文整理了Java中com.evernote.android.job.JobRequest.getTransientExtras()方法的一些代码示例,展示了 ... [详细]
  • 向QTextEdit拖放文件的方法及实现步骤
    本文介绍了在使用QTextEdit时如何实现拖放文件的功能,包括相关的方法和实现步骤。通过重写dragEnterEvent和dropEvent函数,并结合QMimeData和QUrl等类,可以轻松实现向QTextEdit拖放文件的功能。详细的代码实现和说明可以参考本文提供的示例代码。 ... [详细]
  • 阿,里,云,物,联网,net,core,客户端,czgl,aliiotclient, ... [详细]
  • 开发笔记:实验7的文件读写操作
    本文介绍了使用C++的ofstream和ifstream类进行文件读写操作的方法,包括创建文件、写入文件和读取文件的过程。同时还介绍了如何判断文件是否成功打开和关闭文件的方法。通过本文的学习,读者可以了解如何在C++中进行文件读写操作。 ... [详细]
  • Spring框架《一》简介
    Spring框架《一》1.Spring概述1.1简介1.2Spring模板二、IOC容器和Bean1.IOC和DI简介2.三种通过类型获取bean3.给bean的属性赋值3.1依赖 ... [详细]
  • 使用freemaker生成Java代码的步骤及示例代码
    本文介绍了使用freemaker这个jar包生成Java代码的步骤,通过提前编辑好的模板,可以避免写重复代码。首先需要在springboot的pom.xml文件中加入freemaker的依赖包。然后编写模板,定义要生成的Java类的属性和方法。最后编写生成代码的类,通过加载模板文件和数据模型,生成Java代码文件。本文提供了示例代码,并展示了文件目录结构。 ... [详细]
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社区 版权所有