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


Java ByteSource.openStream方法代碼示例

本文整理匯總了Java中com.google.common.io.ByteSource.openStream方法的典型用法代碼示例。如果您正苦於以下問題:Java ByteSource.openStream方法的具體用法?Java ByteSource.openStream怎麽用?Java ByteSource.openStream使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.common.io.ByteSource的用法示例。


在下文中一共展示了ByteSource.openStream方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setSnapshotBytes

import com.google.common.io.ByteSource; //導入方法依賴的package包/類
void setSnapshotBytes(final ByteSource snapshotBytes) throws IOException {
    if (this.snapshotBytes != null) {
        return;
    }

    snapshotSize = snapshotBytes.size();
    snapshotInputStream = snapshotBytes.openStream();

    this.snapshotBytes = snapshotBytes;

    totalChunks = (int) (snapshotSize / snapshotChunkSize + (snapshotSize % snapshotChunkSize > 0 ? 1 : 0));

    LOG.debug("{}: Snapshot {} bytes, total chunks to send: {}", logName, snapshotSize, totalChunks);

    replyReceivedForOffset = -1;
    chunkIndex = FIRST_CHUNK_INDEX;
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:18,代碼來源:LeaderInstallSnapshotState.java

示例2: resource

import com.google.common.io.ByteSource; //導入方法依賴的package包/類
public static InputStream resource(String path) throws IOException {
    try {
        URL url = Resources.getResource(path);
        ByteSource source = Resources.asByteSource(url);
        return source.openStream();
    } catch (IllegalArgumentException ex) {
        throw new MissingObject("template", path);
    }
}
 
開發者ID:LIBCAS,項目名稱:ARCLib,代碼行數:10,代碼來源:Utils.java

示例3: getStream

import com.google.common.io.ByteSource; //導入方法依賴的package包/類
private static Supplier<InputStream> getStream(ByteSource byteSource) {
  return () -> {
    try {
      return byteSource.openStream();
    } catch (IOException e) {
      throw new RuntimeException("Could not open stream", e);
    }
  };
}
 
開發者ID:HubSpot,項目名稱:NioSmtpClient,代碼行數:10,代碼來源:InputStreamMessageContent.java

示例4: reAssembleMessage

import com.google.common.io.ByteSource; //導入方法依賴的package包/類
private static Object reAssembleMessage(final AssembledMessageState state) throws MessageSliceException {
    try {
        final ByteSource assembledBytes = state.getAssembledBytes();
        try (ObjectInputStream in = new ObjectInputStream(assembledBytes.openStream())) {
            return in.readObject();
        }

    } catch (IOException | ClassNotFoundException  e) {
        throw new MessageSliceException(String.format("Error re-assembling bytes for identifier %s",
                state.getIdentifier()), e);
    }
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:13,代碼來源:MessageAssembler.java

示例5: deserializeSnapshot

import com.google.common.io.ByteSource; //導入方法依賴的package包/類
@Override
public State deserializeSnapshot(final ByteSource snapshotBytes) throws IOException {
    try (ObjectInputStream in = new ObjectInputStream(snapshotBytes.openStream())) {
        return new ShardSnapshotState(ShardDataTreeSnapshot.deserialize(in));
    }
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:7,代碼來源:ShardSnapshotCohort.java


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