Chunker

public final class Chunker
extends Object

java.lang.Object
   ↳ com.android.tradefed.cache.remote.Chunker


blob 分割成一或多個 Chunk,最多 chunkSize 個位元組。

blob 完全耗用後 (也就是 hasNext() 傳回 false 時),分塊器會關閉基礎資料來源 (即檔案) 本身。

摘要

巢狀類別

class Chunker.Chunk

Blob 的一部分。 

公用建構函式

Chunker(InputStream blob, long size, int chunkSize)

公用方法

boolean hasNext()

如果後續呼叫 next() 會傳回 Chunk 物件,則傳回 true

Chunker.Chunk next()

傳回下一個 Chunk,或在沒有資料時擲回 NoSuchElementException

公用建構函式

Chunker

public Chunker (InputStream blob, 
                long size, 
                int chunkSize)

參數
blob InputStream

size long

chunkSize int

公用方法

hasNext

public boolean hasNext ()

如果後續呼叫 next() 會傳回 Chunk 物件,則傳回 true

傳回
boolean

下一個

public Chunker.Chunk next ()

傳回下一個 Chunk,如果沒有任何資料,則會擲回 NoSuchElementException

呼叫這個方法前,請務必先呼叫 hasNext()

系統會特別處理零位元組的輸入內容。第一次呼叫 next() 時,系統不會擲回 NoSuchElementException,而是傳回 Chunk,其中包含空白的 ByteString

傳回
Chunker.Chunk

擲回
IOException