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


Java Resources.copy方法代码示例

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


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

示例1: writeSelfReferencingJarFile

import com.google.common.io.Resources; //导入方法依赖的package包/类
private static void writeSelfReferencingJarFile(File jarFile, String... entries)
    throws IOException {
  Manifest manifest = new Manifest();
  // Without version, the manifest is silently ignored. Ugh!
  manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
  manifest.getMainAttributes().put(Attributes.Name.CLASS_PATH, jarFile.getName());

  Closer closer = Closer.create();
  try {
    FileOutputStream fileOut = closer.register(new FileOutputStream(jarFile));
    JarOutputStream jarOut = closer.register(new JarOutputStream(fileOut));
    for (String entry : entries) {
      jarOut.putNextEntry(new ZipEntry(entry));
      Resources.copy(ClassPathTest.class.getResource(entry), jarOut);
      jarOut.closeEntry();
    }
  } catch (Throwable e) {
    throw closer.rethrow(e);
  } finally {
    closer.close();
  }
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:23,代码来源:ClassPathTest.java

示例2: configureTestKeyStore

import com.google.common.io.Resources; //导入方法依赖的package包/类
public static Map<String, File> configureTestKeyStore(File baseDir, File keyStoreFile)
    throws IOException {
  Map<String, File> result = Maps.newHashMap();

  if (System.getProperty("java.vendor").contains("IBM")) {
    Resources.copy(Resources.getResource("ibm-test.keystore"),
        new FileOutputStream(keyStoreFile));
  } else {
    Resources.copy(Resources.getResource("sun-test.keystore"),
        new FileOutputStream(keyStoreFile));
  }

  /* Commands below:
   * keytool -genseckey -alias key-0 -keypass keyPassword -keyalg AES \
   *   -keysize 128 -validity 9000 -keystore src/test/resources/test.keystore \
   *   -storetype jceks -storepass keyStorePassword
   * keytool -genseckey -alias key-1 -keyalg AES -keysize 128 -validity 9000 \
   *   -keystore src/test/resources/test.keystore -storetype jceks \
   *   -storepass keyStorePassword
   */
  // key-0 has own password, key-1 used key store password
  result.put("key-0", TestUtils.writeStringToFile(baseDir, "key-0", "keyPassword"));
  result.put("key-1", null);
  return result;
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:26,代码来源:EncryptionTestUtils.java

示例3: copyTestFile

import com.google.common.io.Resources; //导入方法依赖的package包/类
public static File copyTestFile(String source, TemporaryFolder root, String target) {
    File targetFile = new File(root.getRoot(), target);
    targetFile.getParentFile().mkdirs();
    try (OutputStream stream = new FileOutputStream(targetFile)) {
        Resources.copy(WhoCalled.$.getCallingClass().getResource(source), stream);
        return targetFile;
    } catch (IOException e) {
        throw new AssertionError(e);
    }
}
 
开发者ID:palantir,项目名称:gradle-circle-style,代码行数:11,代码来源:TestCommon.java

示例4: createLogback

import com.google.common.io.Resources; //导入方法依赖的package包/类
private void createLogback ( final Element comp, final EquinoxAppService eas, final File resourceBase ) throws Exception
{
    final Element file = createElement ( comp, "File" ); //$NON-NLS-1$
    final String serviceName = makeServiceName ( eas );
    file.setAttribute ( "Id", "logback.xml_" + serviceName ); //$NON-NLS-1$ //$NON-NLS-2$
    file.setAttribute ( "Source", String.format ( "resources\\apps\\%s\\logback.xml", eas.getName () ) ); //$NON-NLS-1$ //$NON-NLS-2$

    final File logback = new File ( resourceBase, "logback.xml" ); //$NON-NLS-1$
    try ( FileOutputStream out = new FileOutputStream ( logback ) )
    {
        Resources.copy ( Resources.getResource ( MsiHandler.class, "templates/msi/app.logback.xml" ), out ); //$NON-NLS-1$
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:14,代码来源:WixDeploymentSetupBuilder.java


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