本文整理匯總了Java中com.google.common.io.ByteSource.openBufferedStream方法的典型用法代碼示例。如果您正苦於以下問題:Java ByteSource.openBufferedStream方法的具體用法?Java ByteSource.openBufferedStream怎麽用?Java ByteSource.openBufferedStream使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.common.io.ByteSource
的用法示例。
在下文中一共展示了ByteSource.openBufferedStream方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createStream
import com.google.common.io.ByteSource; //導入方法依賴的package包/類
private StreamingOutput createStream(final ByteSource filePart) {
return outputStream -> {
try (InputStream inputStream = filePart.openBufferedStream()) {
ByteStreams.copy(inputStream, outputStream);
}
};
}
示例2: unzipSource
import com.google.common.io.ByteSource; //導入方法依賴的package包/類
private ByteSource unzipSource(ByteSource byteSource) {
return new ByteSource() {
@Override
public InputStream openStream() throws IOException {
ZipInputStream zipInputStream = new ZipInputStream(byteSource.openBufferedStream());
zipInputStream.getNextEntry();//一個zip裏麵就一個文件
return zipInputStream;
}
};
}
示例3: openInputStream
import com.google.common.io.ByteSource; //導入方法依賴的package包/類
@Override
public InputStream openInputStream() throws IOException {
boolean zip = file.getName().endsWith(".zip");
ByteSource byteSource = Files.asByteSource(file);
if (zip) {
byteSource = unzipSource(byteSource);
}
return byteSource.openBufferedStream();
}
示例4: load
import com.google.common.io.ByteSource; //導入方法依賴的package包/類
public boolean load(ByteSource source) throws IOException {
try (InputStream inputStream = source.openBufferedStream()) {
return load(inputStream);
}
}
示例5: getLetsEncryptContext
import com.google.common.io.ByteSource; //導入方法依賴的package包/類
private static SSLContext getLetsEncryptContext() throws Exception {
final URL url = Resources.getResource("DSTRootCAX3.crt");
final ByteSource byteSource = Resources.asByteSource(url);
try (final InputStream inputStream = byteSource.openBufferedStream()) {
final Certificate certificate = CertificateFactory.getInstance("X.509")
.generateCertificate(inputStream);
final KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
keyStore.load(null, null);
keyStore.setCertificateEntry(Integer.toString(1), certificate);
final TrustManagerFactory tmf = TrustManagerFactory.getInstance(
TrustManagerFactory.getDefaultAlgorithm());
tmf.init(keyStore);
final SSLContext context = SSLContext.getInstance("TLS");
context.init(null, tmf.getTrustManagers(), null);
return context;
}
}
示例6: openInputStream
import com.google.common.io.ByteSource; //導入方法依賴的package包/類
@Override
public InputStream openInputStream() throws IOException {
boolean zip = url.toString().endsWith(".zip");
ByteSource byteSource = Resources.asByteSource(url);
if (zip) {
byteSource = unzipSource(byteSource);
}
return byteSource.openBufferedStream();
}