当前位置: 首页>>代码示例>>Java>>正文


Java FileUtil.copy方法代码示例

本文整理汇总了Java中org.knime.core.util.FileUtil.copy方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtil.copy方法的具体用法?Java FileUtil.copy怎么用?Java FileUtil.copy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.knime.core.util.FileUtil的用法示例。


在下文中一共展示了FileUtil.copy方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readBlob

import org.knime.core.util.FileUtil; //导入方法依赖的package包/类
protected DataCell readBlob(ResultSet m_result,int index0) throws SQLException,IOException
	{

       InputStream is = m_result.getBinaryStream(index0);
       if (m_result.wasNull() || is == null) {
           return DataType.getMissingCell();
       } else {
           InputStreamReader reader = new InputStreamReader(is);
           StringWriter writer = new StringWriter();
           FileUtil.copy(reader, writer);
           reader.close();
           writer.close();
           return new StringCell(writer.toString());
       }

}
 
开发者ID:lindenb,项目名称:knime4bio,代码行数:17,代码来源:AbstractSqlNodeModel.java

示例2: createJar

import org.knime.core.util.FileUtil; //导入方法依赖的package包/类
private static void createJar(final DefaultMutableTreeNode node,
		final JarOutputStream jar, final String path) throws IOException {
	Object o = node.getUserObject();
	if (o instanceof String) {
		// folders must end with a "/"
		String subPath = null == path ? "" : (path + (String) o + "/");
		if (path != null) {
			JarEntry je = new JarEntry(subPath);
			jar.putNextEntry(je);
			jar.flush();
			jar.closeEntry();
		}
		for (int i = 0; i < node.getChildCount(); i++) {
			DefaultMutableTreeNode child = (DefaultMutableTreeNode) node
					.getChildAt(i);
			createJar(child, jar, subPath);
		}
	} else {
		Class<?> cl = (Class<?>) o;
		String className = cl.getSimpleName();
		className = className.concat(".class");
		JarEntry entry = new JarEntry(path + className);
		jar.putNextEntry(entry);

		ClassLoader loader = cl.getClassLoader();
		InputStream inStream = loader.getResourceAsStream(cl.getName()
				.replace('.', '/') + ".class");

		FileUtil.copy(inStream, jar);
		inStream.close();
		jar.flush();
		jar.closeEntry();

	}
}
 
开发者ID:pavloff-de,项目名称:spark4knime,代码行数:36,代码来源:JavaSnippet.java

示例3: createJSnippetJarFileForSpark

import org.knime.core.util.FileUtil; //导入方法依赖的package包/类
/**
 * Creates a jar from JSnippet for Spark executor
 * 
 * @param snippetLoader
 * @throws IOException
 * @throws ClassNotFoundException
 * 
 * @author Oleg Pavlov, University of Heidelberg
 */
@SuppressWarnings("unchecked")
private void createJSnippetJarFileForSpark(ClassLoader snippetLoader)
		throws IOException, ClassNotFoundException {
	if (m_snippetJarFile == null) {
		m_snippetJarFile = FileUtil.createTempFile("jsnippetForSpark-",
				".jar", m_tempClassPathDir, true);
	}
	JarOutputStream jar = new JarOutputStream(new FileOutputStream(
			m_snippetJarFile));
	File[] classes = m_tempClassPathDir.listFiles(new FilenameFilter() {
		@Override
		public boolean accept(File dir, String name) {
			return name.endsWith(".class");
		}
	});

	try {
		for (File f : classes) {
			String fileName = f.getName();
			JarEntry entry = new JarEntry(fileName);
			jar.putNextEntry(entry);

			String className = fileName.substring(0,
					fileName.lastIndexOf("."));
			Class<? extends AbstractJSnippet> o = (Class<? extends AbstractJSnippet>) snippetLoader
					.loadClass(className);
			Class<?> cl = (Class<?>) o;

			ClassLoader loader = cl.getClassLoader();
			InputStream inStream = loader.getResourceAsStream(className
					.replace('.', '/') + ".class");

			FileUtil.copy(inStream, jar);
			inStream.close();
			jar.flush();
			jar.closeEntry();
		}
	} finally {
		jar.close();
	}

	JavaSparkContext sc = SparkContexter.getSparkContext(null);
	sc.addJar(m_snippetJarFile.getPath());
}
 
开发者ID:pavloff-de,项目名称:spark4knime,代码行数:54,代码来源:JavaSnippet.java


注:本文中的org.knime.core.util.FileUtil.copy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。