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