/** {@inheritDoc} */ @Override public long size() throws IOException { return ch.size(); }
ch = AsynchronousFileChannel.open(file, opts, vertx.getWorkerPool()); if (options.isAppend()) writePos = ch.size(); } catch (IOException e) { throw new FileSystemException(e);
ch = AsynchronousFileChannel.open(file, opts, vertx.getWorkerPool()); if (options.isAppend()) writePos = ch.size(); } catch (IOException e) { throw new FileSystemException(e);
@Override public long size() throws IOException { return ac.size(); }
/** {@inheritDoc} */ @Override public long size() throws IOException { return ch.size(); }
@Override public long size() throws IOException { return chan.size(); }
public long size() throws IOException { return ac.size(); }
public long length() { try { return fileChannel.size(); } catch (IOException e) { FSTUtil.<RuntimeException>rethrow(e); } return -1; }
/** * @param id ID. * @param file Existing file. * @throws IOException If failed. */ LogFile(long id, Path file) throws IOException { this.id = id; this.file = file; init = null; acquiredSize = null; readCh = AsynchronousFileChannel.open(file, StandardOpenOption.READ); size = readCh.size(); }
public long length() { try { return fileChannel.size(); } catch (IOException e) { FSTUtil.<RuntimeException>rethrow(e); } return -1; }
public void start(Operation op, String file, int maxLines) throws IOException { this.channel = AsynchronousFileChannel.open(Paths.get(file), StandardOpenOption.READ); long size = this.channel.size(); this.chunks = size / CHUNK_SIZE; this.maxLines = maxLines; int firstChunkSize = (int) (size % CHUNK_SIZE); if (firstChunkSize > 0) { this.chunks++; } else { firstChunkSize = CHUNK_SIZE; } read(op, firstChunkSize); }
public void start(Operation op, String file, int maxLines) throws IOException { this.channel = AsynchronousFileChannel.open(Paths.get(file), StandardOpenOption.READ); long size = this.channel.size(); this.chunks = size / CHUNK_SIZE; this.maxLines = maxLines; int firstChunkSize = (int) (size % CHUNK_SIZE); if (firstChunkSize > 0) { this.chunks++; } else { firstChunkSize = CHUNK_SIZE; } read(op, firstChunkSize); }
/** * Creates a {@link Flowable} from an {@link AsynchronousFileChannel} * which reads the entire file. * * @param fileChannel The file channel. * @return The AsyncInputStream. */ public static Flowable<ByteBuffer> readFile(AsynchronousFileChannel fileChannel) { try { long size = fileChannel.size(); return readFile(fileChannel, DEFAULT_CHUNK_SIZE, 0, size); } catch (IOException e) { return Flowable.error(e); } }
private void done() throws IOException { if (fileChannel != null) { if (!contentStream.isEmpty()) { ByteBuffer bb = ByteBuffer.allocate(contentStream.length()); bb.put(contentStream.toByteArray()); bb.flip(); contentStream.clear(); fileChannel.write(bb, fileChannel.size()); fileChannel.close(); } } }
private void done() throws IOException { if (fileChannel != null) { if (!contentStream.isEmpty()) { ByteBuffer bb = ByteBuffer.allocate(contentStream.length()); bb.put(contentStream.toByteArray()); bb.flip(); contentStream.clear(); fileChannel.write(bb, fileChannel.size()); fileChannel.close(); } } }
@Override public boolean configure(Properties properties) { try { destination = AsynchronousFileChannel.open(Paths.get(fileName), StandardOpenOption.WRITE, StandardOpenOption.CREATE); // Failed to used StandardOpenOption.(APPEND vs CREATE), so truncate if need after creation if (truncate) { destination.truncate(0); } position = new AtomicLong(destination.size()); } catch (IOException | UnsupportedOperationException e) { logger.error("error openening output file {}: {}", fileName, Helpers.resolveThrowableException(e)); logger.catching(Level.DEBUG, e); return false; } return super.configure(properties); }
private void save(boolean saveLaterIfWriting) { // atomically sets to true if false: boolean canSaveNow = currentlyWriting.compareAndSet(false, true); if (canSaveNow) {// no writing is in progress: start one immediately // Writes the config data to a ByteBuffer CharsWrapper.Builder builder = new CharsWrapper.Builder(512); writer.write(config, builder); CharBuffer chars = CharBuffer.wrap(builder.build()); ByteBuffer buffer = charset.encode(chars); // Writes the ByteBuffer to the nioPath, asynchronously synchronized (channelGuard) { try { channel = AsynchronousFileChannel.open(nioPath, openOptions); channel.write(buffer, channel.size(), null, writeCompletedHandler); } catch (IOException e) { writeCompletedHandler.failed(e, null); } } } else if (saveLaterIfWriting) {// there is a writing in progress: start one later mustWriteAgain.set(true); } }
this.projectedSize = new AtomicLong(channel.size());
bb.put(contentStream.toByteArray()); bb.flip(); fileChannel.write(bb, fileChannel.size()); contentStream.clear();
bb.put(contentStream.toByteArray()); bb.flip(); fileChannel.write(bb, fileChannel.size()); contentStream.clear();