當前位置: 首頁>>代碼示例>>Java>>正文


Java ByteSource.openBufferedStream方法代碼示例

本文整理匯總了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);
    }
  };
}
 
開發者ID:andreschaffer,項目名稱:http-progressive-download-examples,代碼行數:8,代碼來源:VideoResource.java

示例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;
        }
    };
}
 
開發者ID:mayabot,項目名稱:mynlp,代碼行數:11,代碼來源:URLMynlpResource.java

示例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();
}
 
開發者ID:mayabot,項目名稱:mynlp,代碼行數:13,代碼來源:FileMynlpResource.java

示例4: load

import com.google.common.io.ByteSource; //導入方法依賴的package包/類
public boolean load(ByteSource source) throws IOException {
    try (InputStream inputStream = source.openBufferedStream()) {
        return load(inputStream);
    }
}
 
開發者ID:mayabot,項目名稱:mynlp,代碼行數:6,代碼來源:TransformMatrix.java

示例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;
        }
    }
 
開發者ID:LoopPerfect,項目名稱:buckaroo,代碼行數:28,代碼來源:LoggingTasks.java

示例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();

}
 
開發者ID:mayabot,項目名稱:mynlp,代碼行數:15,代碼來源:URLMynlpResource.java


注:本文中的com.google.common.io.ByteSource.openBufferedStream方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。