本文整理汇总了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;
}
示例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;
}
}
}
示例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);
}
}
示例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();
}
}