APISonar


com.google.common.io.Files.newInputStreamSupplier

> com > google > common > io > Files > newInputStreamSupplier
com APIs google APIs common APIs io APIs Files APIs newInputStreamSupplier APIs

Example 1
public static File readResourceToTempFile(String resourceName) throws IOException {
    InputSupplier<? extends InputStream> inSupplier;
    try {
      URL resourceURL = Resources.getResource(GroupLensRecommender.class, resourceName);
      inSupplier = Resources.newInputStreamSupplier(resourceURL);
    } catch (IllegalArgumentException iae) {
      File resourceFile = new File("src/main/java" + resourceName);
      inSupplier = Files.newInputStreamSupplier(resourceFile);
    }
    File tempFile = File.createTempFile("taste", null);
    tempFile.deleteOnExit();
    Files.copy(inSupplier, tempFile);
    return tempFile;
  }
Example 2
static void uploadJar(File jarFile, final Path path, final FileSystem fs) throws IOException
  {
    log.info("Uploading jar to path[%s]", path);
    ByteStreams.copy(
        Files.newInputStreamSupplier(jarFile),
        new OutputSupplier<OutputStream>()
        {
          @Override
          public OutputStream getOutput() throws IOException
          {
            return fs.create(path);
          }
        }
    );
  }
Example 3
public InputSupplier<? extends InputStream> getInputSupplierForRelativePath(Path path) {
    Path file = getPathForRelativePath(path);
    return Files.newInputStreamSupplier(file.toFile());
  }
Example 4
public DefaultFileHashCache(ProjectFilesystem projectFilesystem, Console console) {
    this.projectFilesystem = Preconditions.checkNotNull(projectFilesystem);
    this.console = Preconditions.checkNotNull(console);

    this.loadingCache = CacheBuilder.newBuilder()
        .build(new CacheLoader<Path, HashCode>() {
          @Override
          public HashCode load(Path path) throws Exception {
            File file = DefaultFileHashCache.this.projectFilesystem.resolve(path).toFile();
            InputSupplier<? extends InputStream> inputSupplier = Files.newInputStreamSupplier(file);
            return ByteStreams.hash(inputSupplier, Hashing.sha1());
          }
        });
  }