当前位置: 首页>>代码示例>>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;未经允许,请勿转载。