/** * Deletes the file underlying the given channel. If the channel is still open, this * call may fail. * * @param channel The channel to be deleted. * @throws IOException Thrown if the deletion fails. */ public void deleteChannel(FileIOChannel.ID channel) throws IOException { if (channel != null) { if (channel.getPathFile().exists() && !channel.getPathFile().delete()) { LOG.warn("IOManager failed to delete temporary file {}", channel.getPath()); } } }
/** * Deletes the file underlying the given channel. If the channel is still open, this * call may fail. * * @param channel The channel to be deleted. * @throws IOException Thrown if the deletion fails. */ public void deleteChannel(FileIOChannel.ID channel) throws IOException { if (channel != null) { if (channel.getPathFile().exists() && !channel.getPathFile().delete()) { LOG.warn("IOManager failed to delete temporary file {}", channel.getPath()); } } }
/** * Deletes the file underlying the given channel. If the channel is still open, this * call may fail. * * @param channel The channel to be deleted. * @throws IOException Thrown if the deletion fails. */ public void deleteChannel(FileIOChannel.ID channel) throws IOException { if (channel != null) { if (channel.getPathFile().exists() && !channel.getPathFile().delete()) { LOG.warn("IOManager failed to delete temporary file {}", channel.getPath()); } } }
@Override public void readInto(Buffer buffer, long length) throws IOException { if (!withHeader) { if (fileChannel.size() - currentPosition > 0) { hasReachedEndOfFile = StreamFileChannelReader.readBufferFromFileChannel( fileChannel, buffer, currentPosition, length, id.getPathFile()); currentPosition += length; } else { buffer.recycleBuffer(); // In case of empty file. if (!hasReachedEndOfFile) { hasReachedEndOfFile = true; } } } else { throw new IllegalArgumentException("Method readInto(Buffer buffer, long length) only support withoutHeader mode."); } }
@Override public void read() throws IOException { if (!hasReachedEndOfFile.get()) { if (bufferSize == -1) { hasReachedEndOfFile.set(StreamFileChannelReader.readBufferFromFileChannel( channel.fileChannel, buffer, startPosition, bytesToRead, channel.id.getPathFile())); } else { NioBufferedFileInputStream in = channel.getBufferedInputStream(bufferSize); if (in.available() > 0) { hasReachedEndOfFile.set(StreamFileChannelReader.readBufferFromFileBufferedChannel( in, buffer, startPosition, bytesToRead, channel.id.getPathFile())); } else { hasReachedEndOfFile.set(true); } } } }
/** * Deletes the file underlying the given channel. If the channel is still open, this * call may fail. * * @param channel The channel to be deleted. * @throws IOException Thrown if the deletion fails. */ public void deleteChannel(FileIOChannel.ID channel) throws IOException { if (channel != null) { if (channel.getPathFile().exists() && !channel.getPathFile().delete()) { LOG.warn("IOManager failed to delete temporary file {}", channel.getPath()); } } }