本文整理匯總了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;
}
示例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);
}
}
示例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);
}
};
}
示例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);
}
}
示例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));
}
}