com.google.common.io.Files.newOutputStreamSupplier()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(7.6k)|赞(0)|评价(0)|浏览(95)

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

Files.newOutputStreamSupplier介绍

[英]Returns a factory that will supply instances of FileOutputStreamthat write to a file.
[中]返回将提供写入文件的FileOutputStream实例的工厂。

代码示例

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

/**
 * Returns a factory that will supply instances of {@link FileOutputStream}
 * that write to a file.
 *
 * @param file the file to write to
 * @return the factory
 */
public static OutputSupplier<FileOutputStream> newOutputStreamSupplier(
  File file) {
 return newOutputStreamSupplier(file, false);
}

代码示例来源:origin: com.atlassian.bundles/guava

/**
 * Returns a factory that will supply instances of {@link FileOutputStream}
 * that write to a file.
 *
 * @param file the file to write to
 * @return the factory
 */
public static OutputSupplier<FileOutputStream> newOutputStreamSupplier(
  File file) {
 return newOutputStreamSupplier(file, false);
}

代码示例来源:origin: org.hudsonci.lib.guava/guava

/**
 * Returns a factory that will supply instances of {@link FileOutputStream}
 * that write to a file.
 *
 * @param file the file to write to
 * @return the factory
 */
public static OutputSupplier<FileOutputStream> newOutputStreamSupplier(
  File file) {
 return newOutputStreamSupplier(file, false);
}

代码示例来源:origin: org.sonatype.sisu/sisu-guava

/**
 * Returns a factory that will supply instances of {@link FileOutputStream}
 * that write to a file.
 *
 * @param file the file to write to
 * @return the factory
 */
public static OutputSupplier<FileOutputStream> newOutputStreamSupplier(
  File file) {
 return newOutputStreamSupplier(file, false);
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics

/**
 * Returns a factory that will supply instances of {@link FileOutputStream}
 * that write to a file.
 *
 * @param file the file to write to
 * @return the factory
 */
public static OutputSupplier<FileOutputStream> newOutputStreamSupplier(
  File file) {
 return newOutputStreamSupplier(file, false);
}

代码示例来源:origin: com.google.guava/guava-io

/**
 * Returns a factory that will supply instances of {@link FileOutputStream}
 * that write to a file.
 *
 * @param file the file to write to
 * @return the factory
 */
public static OutputSupplier<FileOutputStream> newOutputStreamSupplier(
  File file) {
 return newOutputStreamSupplier(file, false);
}

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/com.google.guava

/**
 * Returns a factory that will supply instances of {@link FileOutputStream}
 * that write to a file.
 *
 * @param file the file to write to
 * @return the factory
 */
public static OutputSupplier<FileOutputStream> newOutputStreamSupplier(
  File file) {
 return newOutputStreamSupplier(file, false);
}

代码示例来源:origin: com.atlassian.bundles/guava

/**
 * Copies to a file all bytes from an {@link InputStream} supplied by a
 * factory.
 *
 * @param from the input factory
 * @param to the destination file
 * @throws IOException if an I/O error occurs
 */
public static void copy(InputSupplier<? extends InputStream> from, File to)
  throws IOException {
 ByteStreams.copy(from, newOutputStreamSupplier(to));
}

代码示例来源:origin: com.google.guava/guava-io

/**
 * Copies to a file all bytes from an {@link InputStream} supplied by a
 * factory.
 *
 * @param from the input factory
 * @param to the destination file
 * @throws IOException if an I/O error occurs
 */
public static void copy(InputSupplier<? extends InputStream> from, File to)
  throws IOException {
 ByteStreams.copy(from, newOutputStreamSupplier(to));
}

代码示例来源:origin: org.sonatype.sisu/sisu-guava

/**
 * Copies to a file all bytes from an {@link InputStream} supplied by a
 * factory.
 *
 * @param from the input factory
 * @param to the destination file
 * @throws IOException if an I/O error occurs
 */
public static void copy(InputSupplier<? extends InputStream> from, File to)
  throws IOException {
 ByteStreams.copy(from, newOutputStreamSupplier(to));
}

代码示例来源:origin: co.cask.tigon/tigon-yarn

private static void unJar(ZipInputStream jarInputStream, File targetDirectory) throws IOException {
 ZipEntry entry;
 while ((entry = jarInputStream.getNextEntry()) != null) {
  File output = new File(targetDirectory, entry.getName());
  if (entry.isDirectory()) {
   output.mkdirs();
  } else {
   output.getParentFile().mkdirs();
   ByteStreams.copy(jarInputStream, Files.newOutputStreamSupplier(output));
  }
 }
}

代码示例来源:origin: com.google.guava/guava-io

/**
 * Overwrites a file with the contents of a byte array.
 *
 * @param from the bytes to write
 * @param to the destination file
 * @throws IOException if an I/O error occurs
 */
public static void write(byte[] from, File to) throws IOException {
 ByteStreams.write(from, newOutputStreamSupplier(to));
}

代码示例来源:origin: com.atlassian.bundles/guava

/**
 * Overwrites a file with the contents of a byte array.
 *
 * @param from the bytes to write
 * @param to the destination file
 * @throws IOException if an I/O error occurs
 */
public static void write(byte[] from, File to) throws IOException {
 ByteStreams.write(from, newOutputStreamSupplier(to));
}

代码示例来源:origin: co.cask.cdap/cdap-unit-test

private static void copyTempFile(String infileName, File outDir) throws IOException {
 URL url = TestBase.class.getClassLoader().getResource(infileName);
 if (url == null) {
  throw new IOException("Failed to get resource for " + infileName);
 }
 File outFile = new File(outDir, infileName);
 ByteStreams.copy(Resources.newInputStreamSupplier(url), Files.newOutputStreamSupplier(outFile));
}

代码示例来源:origin: caskdata/cdap

private static void copyTempFile(String infileName, File outDir) throws IOException {
 URL url = TestBase.class.getClassLoader().getResource(infileName);
 if (url == null) {
  throw new IOException("Failed to get resource for " + infileName);
 }
 File outFile = new File(outDir, infileName);
 ByteStreams.copy(Resources.newInputStreamSupplier(url), Files.newOutputStreamSupplier(outFile));
}

代码示例来源:origin: org.sonatype.sisu/sisu-guava

/**
 * Overwrites a file with the contents of a byte array.
 *
 * @param from the bytes to write
 * @param to the destination file
 * @throws IOException if an I/O error occurs
 */
public static void write(byte[] from, File to) throws IOException {
 ByteStreams.write(from, newOutputStreamSupplier(to));
}

代码示例来源:origin: MinecraftForge/Installer

private void doFileExtract(File path) throws IOException
{
  if (Strings.isNullOrEmpty(getContainedFile())) return;
  System.out.println("Extracting: /" + getContainedFile());
  System.out.println("To:          " + path.getAbsolutePath());
  InputStream inputStream = getClass().getResourceAsStream("/"+getContainedFile());
  OutputSupplier<FileOutputStream> outputSupplier = Files.newOutputStreamSupplier(path);
  ByteStreams.copy(inputStream, outputSupplier);
}

代码示例来源:origin: caskdata/cdap

public static void debugByteCode(ClassDefinition classDefinition, PrintWriter writer) {
 ClassReader reader = new ClassReader(classDefinition.getBytecode());
 reader.accept(new CheckClassAdapter(new TraceClassVisitor(writer)), 0);
 File file = new File("/tmp/" + classDefinition.getInternalName() + ".class");
 file.getParentFile().mkdirs();
 writer.println(file);
 writer.flush();
 try {
  ByteStreams.write(classDefinition.getBytecode(), Files.newOutputStreamSupplier(file));
 } catch (IOException e) {
  e.printStackTrace();
 }
}

代码示例来源:origin: co.cask.tigon/tigon-yarn

public static void debugByteCode(ClassDefinition classDefinition, PrintWriter writer) {
 ClassReader reader = new ClassReader(classDefinition.getBytecode());
 reader.accept(new CheckClassAdapter(new TraceClassVisitor(writer)), 0);
 File file = new File("/tmp/" + classDefinition.getInternalName() + ".class");
 file.getParentFile().mkdirs();
 writer.println(file);
 writer.flush();
 try {
  ByteStreams.write(classDefinition.getBytecode(), Files.newOutputStreamSupplier(file));
 } catch (IOException e) {
  e.printStackTrace();
 }
}

代码示例来源:origin: com.n3twork.druid/druid-processing

@Override
 public void close() throws IOException
 {
  final File outFile = IndexIO.makeMetricFile(outDir, metricName, IndexIO.BYTE_ORDER);
  outFile.delete();
  MetricHolder.writeFloatMetric(
    Files.newOutputStreamSupplier(outFile, true), metricName, writer
  );
  IndexIO.checkFileSize(outFile);

  writer = null;
 }
}

相关文章