com.google.common.io.OutputSupplier Java Examples
The following examples show how to use
com.google.common.io.OutputSupplier.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PhantomJsDownloader.java From blog with MIT License | 6 votes |
private void downloadZip(String url, File targetZip) { if (targetZip.exists()) { return; } File zipTemp = new File(targetZip.getAbsolutePath() + ".temp"); try { zipTemp.getParentFile().mkdirs(); InputSupplier<InputStream> input = Resources .newInputStreamSupplier(URI.create(url).toURL()); OutputSupplier<FileOutputStream> ouput = Files .newOutputStreamSupplier(zipTemp); ByteStreams.copy(input, ouput); } catch (IOException e) { String message = "Unable to download phantomjs from " + url; throw new IllegalStateException(message, e); } zipTemp.renameTo(targetZip); }
Example #2
Source File: PhantomJsDownloader.java From blog with MIT License | 6 votes |
private void downloadZip(String url, File targetZip) { if (targetZip.exists()) { return; } File zipTemp = new File(targetZip.getAbsolutePath() + ".temp"); try { zipTemp.getParentFile().mkdirs(); InputSupplier<InputStream> input = Resources .newInputStreamSupplier(URI.create(url).toURL()); OutputSupplier<FileOutputStream> ouput = Files .newOutputStreamSupplier(zipTemp); ByteStreams.copy(input, ouput); } catch (IOException e) { String message = "Unable to download phantomjs from " + url; throw new IllegalStateException(message, e); } zipTemp.renameTo(targetZip); }
Example #3
Source File: PhantomJsDownloader.java From blog with MIT License | 6 votes |
private void downloadZip(String url, File targetZip) { if (targetZip.exists()) { return; } File zipTemp = new File(targetZip.getAbsolutePath() + ".temp"); try { zipTemp.getParentFile().mkdirs(); InputSupplier<InputStream> input = Resources .newInputStreamSupplier(URI.create(url).toURL()); OutputSupplier<FileOutputStream> ouput = Files .newOutputStreamSupplier(zipTemp); ByteStreams.copy(input, ouput); } catch (IOException e) { String message = "Unable to download phantomjs from " + url; throw new IllegalStateException(message, e); } zipTemp.renameTo(targetZip); }
Example #4
Source File: YarnTwillPreparer.java From twill with Apache License 2.0 | 5 votes |
private void saveArguments(Arguments arguments, final Path targetPath) throws IOException { LOG.debug("Creating {}", targetPath); ArgumentsCodec.encode(arguments, new OutputSupplier<Writer>() { @Override public Writer getOutput() throws IOException { return Files.newBufferedWriter(targetPath, StandardCharsets.UTF_8); } }); LOG.debug("Done {}", targetPath); }
Example #5
Source File: ArgumentsCodec.java From twill with Apache License 2.0 | 4 votes |
public static void encode(Arguments arguments, OutputSupplier<? extends Writer> writerSupplier) throws IOException { try (Writer writer = writerSupplier.getOutput()) { GSON.toJson(arguments, writer); } }