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


Java IOUtils.EOF屬性代碼示例

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


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

示例1: readNextChunk

private int readNextChunk() throws IOException {
    final ByteBuffer ciphertextBuf = ByteBuffer.allocate(chunkSize);
    final int read = IOUtils.read(proxy, ciphertextBuf.array());
    if(read == 0) {
        return IOUtils.EOF;
    }
    ciphertextBuf.position(read);
    ciphertextBuf.flip();
    try {
        buffer = cryptor.fileContentCryptor().decryptChunk(ciphertextBuf, chunkIndexOffset++, header, true);
    }
    catch(CryptoException e) {
        throw new IOException(e.getMessage(), new CryptoAuthenticationException(e.getMessage(), e));
    }
    return read;
}
 
開發者ID:iterate-ch,項目名稱:cyberduck,代碼行數:16,代碼來源:CryptoInputStream.java

示例2: read

@Override
public synchronized int read(final byte[] chunk, final Long offset) throws IOException {
    final RandomAccessFile file = random();
    if(offset < file.length()) {
        file.seek(offset);
        if(chunk.length + offset > file.length()) {
            return file.read(chunk, 0, (int) (file.length() - offset));
        }
        else {
            return file.read(chunk, 0, chunk.length);
        }
    }
    else {
        final NullInputStream nullStream = new NullInputStream(length);
        if(nullStream.available() > 0) {
            nullStream.skip(offset);
            return nullStream.read(chunk, 0, chunk.length);
        }
        else {
            return IOUtils.EOF;
        }
    }
}
 
開發者ID:iterate-ch,項目名稱:cyberduck,代碼行數:23,代碼來源:FileBuffer.java

示例3: readNextChunk

private int readNextChunk() throws IOException {
    final ByteBuffer ciphertextBuf = ByteBuffer.allocate(SDSSession.DEFAULT_CHUNKSIZE);
    final int read = IOUtils.read(proxy, ciphertextBuf.array());
    if(lastread == 0) {
        return IOUtils.EOF;
    }
    ciphertextBuf.position(read);
    ciphertextBuf.flip();
    try {
        final PlainDataContainer pDataContainer;
        if(read == 0) {
            final PlainDataContainer c1 = cipher.processBytes(createEncryptedDataContainer(ciphertextBuf.array(), read, null));
            final PlainDataContainer c2 = cipher.doFinal(new EncryptedDataContainer(null, tag));
            pDataContainer = new PlainDataContainer(ArrayUtils.addAll(c1.getContent(), c2.getContent()));
        }
        else {
            pDataContainer = cipher.processBytes(createEncryptedDataContainer(ciphertextBuf.array(), read, null));
        }
        final byte[] content = pDataContainer.getContent();
        buffer = ByteBuffer.allocate(content.length);
        buffer.put(content);
        buffer.flip();
        lastread = read;
        return content.length;
    }
    catch(CryptoException e) {
        throw new IOException(e);
    }
}
 
開發者ID:iterate-ch,項目名稱:cyberduck,代碼行數:29,代碼來源:CryptoInputStream.java

示例4: getResponseBytes

@Nullable
protected final byte[] getResponseBytes(HttpResponse response) throws IOException, HttpException {
    try (InputStream stream = HttpUtils.getContent(response.getEntity())) {
        ByteArrayOutputStream output = new ByteArrayOutputStream();
        int n;
        byte[] buffer = new byte[BUFFER_SIZE];
        while (IOUtils.EOF != (n = stream.read(buffer)) && !isInterrupted()) {
            output.write(buffer, 0, n);
        }
        return isInterrupted() ? null : output.toByteArray();
    }
}
 
開發者ID:kalikov,項目名稱:lighthouse,代碼行數:12,代碼來源:AbstractHttpLoader.java


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