List of usage examples for com.google.common.io ByteSource wrap
public static ByteSource wrap(byte[] b)
From source file:org.pantsbuild.tools.jar.JarBuilder.java
/** * Registers the given Manifest to be used in the jar written out by {@link #write}. * * @param customManifest The manifest to use for the built jar. * @return This builder for chaining./*from ww w . j a v a 2s.co m*/ */ public JarBuilder useCustomManifest(CharSequence customManifest) { Preconditions.checkNotNull(customManifest); return useCustomManifest(NamedByteSource.create(memorySource(), JarFile.MANIFEST_NAME, ByteSource.wrap(customManifest.toString().getBytes(Charsets.UTF_8)))); }
From source file:org.eclipse.che.vfs.impl.fs.FSMountPoint.java
private String countHashSum(VirtualFile virtualFile, HashFunction hashFunction) throws ServerException { final PathLockFactory.PathLock lock = pathLockFactory.getLock(virtualFile.getVirtualFilePath(), false) .acquire(LOCK_FILE_TIMEOUT); try (InputStream contentStream = virtualFile.getContent().getStream()) { return ByteSource.wrap(ByteStreams.toByteArray(contentStream)).hash(hashFunction).toString(); } catch (ForbiddenException e) { throw new ServerException(e.getServiceError()); } catch (IOException e) { throw new ServerException(e); } finally {// w w w. ja v a2s. c om lock.release(); } }