java.nio.channels.NonWritableChannelException Java Examples
The following examples show how to use
java.nio.channels.NonWritableChannelException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FileChannelImpl.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
public long transferFrom(ReadableByteChannel src, long position, long count) throws IOException { ensureOpen(); if (!src.isOpen()) throw new ClosedChannelException(); if (!writable) throw new NonWritableChannelException(); if ((position < 0) || (count < 0)) throw new IllegalArgumentException(); if (position > size()) return 0; if (src instanceof FileChannelImpl) return transferFromFileChannel((FileChannelImpl)src, position, count); return transferFromArbitraryChannel(src, position, count); }
Example #2
Source File: FileChannelImpl.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public int write(ByteBuffer src, long position) throws IOException { if (src == null) throw new NullPointerException(); if (position < 0) throw new IllegalArgumentException("Negative position"); if (!writable) throw new NonWritableChannelException(); ensureOpen(); if (nd.needsPositionLock()) { synchronized (positionLock) { return writeInternal(src, position); } } else { return writeInternal(src, position); } }
Example #3
Source File: FileChannelImpl.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
public long transferFrom(ReadableByteChannel src, long position, long count) throws IOException { ensureOpen(); if (!src.isOpen()) throw new ClosedChannelException(); if (!writable) throw new NonWritableChannelException(); if ((position < 0) || (count < 0)) throw new IllegalArgumentException(); if (position > size()) return 0; if (src instanceof FileChannelImpl) return transferFromFileChannel((FileChannelImpl)src, position, count); return transferFromArbitraryChannel(src, position, count); }
Example #4
Source File: FileChannelImpl.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
public int write(ByteBuffer src, long position) throws IOException { if (src == null) throw new NullPointerException(); if (position < 0) throw new IllegalArgumentException("Negative position"); if (!writable) throw new NonWritableChannelException(); ensureOpen(); if (nd.needsPositionLock()) { synchronized (positionLock) { return writeInternal(src, position); } } else { return writeInternal(src, position); } }
Example #5
Source File: FileChannelImpl.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public long transferFrom(ReadableByteChannel src, long position, long count) throws IOException { ensureOpen(); if (!src.isOpen()) throw new ClosedChannelException(); if (!writable) throw new NonWritableChannelException(); if ((position < 0) || (count < 0)) throw new IllegalArgumentException(); if (position > size()) return 0; if (src instanceof FileChannelImpl) return transferFromFileChannel((FileChannelImpl)src, position, count); return transferFromArbitraryChannel(src, position, count); }
Example #6
Source File: FileChannelImpl.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
public int write(ByteBuffer src, long position) throws IOException { if (src == null) throw new NullPointerException(); if (position < 0) throw new IllegalArgumentException("Negative position"); if (!writable) throw new NonWritableChannelException(); ensureOpen(); if (nd.needsPositionLock()) { synchronized (positionLock) { return writeInternal(src, position); } } else { return writeInternal(src, position); } }
Example #7
Source File: FileChannelImpl.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public long transferFrom(ReadableByteChannel src, long position, long count) throws IOException { ensureOpen(); if (!src.isOpen()) throw new ClosedChannelException(); if (!writable) throw new NonWritableChannelException(); if ((position < 0) || (count < 0)) throw new IllegalArgumentException(); if (position > size()) return 0; if (src instanceof FileChannelImpl) return transferFromFileChannel((FileChannelImpl)src, position, count); return transferFromArbitraryChannel(src, position, count); }
Example #8
Source File: FileChannelImpl.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public int write(ByteBuffer src, long position) throws IOException { if (src == null) throw new NullPointerException(); if (position < 0) throw new IllegalArgumentException("Negative position"); if (!writable) throw new NonWritableChannelException(); ensureOpen(); if (nd.needsPositionLock()) { synchronized (positionLock) { return writeInternal(src, position); } } else { return writeInternal(src, position); } }
Example #9
Source File: FileChannelImpl.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
public long transferFrom(ReadableByteChannel src, long position, long count) throws IOException { ensureOpen(); if (!src.isOpen()) throw new ClosedChannelException(); if (!writable) throw new NonWritableChannelException(); if ((position < 0) || (count < 0)) throw new IllegalArgumentException(); if (position > size()) return 0; if (src instanceof FileChannelImpl) return transferFromFileChannel((FileChannelImpl)src, position, count); return transferFromArbitraryChannel(src, position, count); }
Example #10
Source File: FileChannelImpl.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
public long transferFrom(ReadableByteChannel src, long position, long count) throws IOException { ensureOpen(); if (!src.isOpen()) throw new ClosedChannelException(); if (!writable) throw new NonWritableChannelException(); if ((position < 0) || (count < 0)) throw new IllegalArgumentException(); if (position > size()) return 0; if (src instanceof FileChannelImpl) return transferFromFileChannel((FileChannelImpl)src, position, count); return transferFromArbitraryChannel(src, position, count); }
Example #11
Source File: FileChannelImpl.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
public int write(ByteBuffer src, long position) throws IOException { if (src == null) throw new NullPointerException(); if (position < 0) throw new IllegalArgumentException("Negative position"); if (!writable) throw new NonWritableChannelException(); ensureOpen(); if (nd.needsPositionLock()) { synchronized (positionLock) { return writeInternal(src, position); } } else { return writeInternal(src, position); } }
Example #12
Source File: FileChannelImpl.java From Bytecoder with Apache License 2.0 | 6 votes |
public long transferFrom(ReadableByteChannel src, long position, long count) throws IOException { ensureOpen(); if (!src.isOpen()) throw new ClosedChannelException(); if (!writable) throw new NonWritableChannelException(); if ((position < 0) || (count < 0)) throw new IllegalArgumentException(); if (position > size()) return 0; if (src instanceof FileChannelImpl) return transferFromFileChannel((FileChannelImpl)src, position, count); return transferFromArbitraryChannel(src, position, count); }
Example #13
Source File: FileChannelImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public long transferFrom(ReadableByteChannel src, long position, long count) throws IOException { ensureOpen(); if (!src.isOpen()) throw new ClosedChannelException(); if (!writable) throw new NonWritableChannelException(); if ((position < 0) || (count < 0)) throw new IllegalArgumentException(); if (position > size()) return 0; if (src instanceof FileChannelImpl) return transferFromFileChannel((FileChannelImpl)src, position, count); return transferFromArbitraryChannel(src, position, count); }
Example #14
Source File: FileChannelImpl.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
public long transferFrom(ReadableByteChannel src, long position, long count) throws IOException { ensureOpen(); if (!src.isOpen()) throw new ClosedChannelException(); if (!writable) throw new NonWritableChannelException(); if ((position < 0) || (count < 0)) throw new IllegalArgumentException(); if (position > size()) return 0; if (src instanceof FileChannelImpl) return transferFromFileChannel((FileChannelImpl)src, position, count); return transferFromArbitraryChannel(src, position, count); }
Example #15
Source File: FileChannelImpl.java From hottub with GNU General Public License v2.0 | 6 votes |
public long transferFrom(ReadableByteChannel src, long position, long count) throws IOException { ensureOpen(); if (!src.isOpen()) throw new ClosedChannelException(); if (!writable) throw new NonWritableChannelException(); if ((position < 0) || (count < 0)) throw new IllegalArgumentException(); if (position > size()) return 0; if (src instanceof FileChannelImpl) return transferFromFileChannel((FileChannelImpl)src, position, count); return transferFromArbitraryChannel(src, position, count); }
Example #16
Source File: FileChannelImpl.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
public int write(ByteBuffer src, long position) throws IOException { if (src == null) throw new NullPointerException(); if (position < 0) throw new IllegalArgumentException("Negative position"); if (!writable) throw new NonWritableChannelException(); ensureOpen(); if (nd.needsPositionLock()) { synchronized (positionLock) { return writeInternal(src, position); } } else { return writeInternal(src, position); } }
Example #17
Source File: FileChannelImpl.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
public long transferFrom(ReadableByteChannel src, long position, long count) throws IOException { ensureOpen(); if (!src.isOpen()) throw new ClosedChannelException(); if (!writable) throw new NonWritableChannelException(); if ((position < 0) || (count < 0)) throw new IllegalArgumentException(); if (position > size()) return 0; if (src instanceof FileChannelImpl) return transferFromFileChannel((FileChannelImpl)src, position, count); return transferFromArbitraryChannel(src, position, count); }
Example #18
Source File: FileChannelImpl.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
public int write(ByteBuffer src, long position) throws IOException { if (src == null) throw new NullPointerException(); if (position < 0) throw new IllegalArgumentException("Negative position"); if (!writable) throw new NonWritableChannelException(); ensureOpen(); if (nd.needsPositionLock()) { synchronized (positionLock) { return writeInternal(src, position); } } else { return writeInternal(src, position); } }
Example #19
Source File: FileSystemStorage.java From pravega with Apache License 2.0 | 6 votes |
private <T> T throwException(String segmentName, Exception e) throws StreamSegmentException { if (e instanceof NoSuchFileException || e instanceof FileNotFoundException) { throw new StreamSegmentNotExistsException(segmentName); } if (e instanceof FileAlreadyExistsException) { throw new StreamSegmentExistsException(segmentName); } if (e instanceof IndexOutOfBoundsException) { throw new IllegalArgumentException(e.getMessage()); } if (e instanceof AccessControlException || e instanceof AccessDeniedException || e instanceof NonWritableChannelException) { throw new StreamSegmentSealedException(segmentName, e); } throw Exceptions.sneakyThrow(e); }
Example #20
Source File: FileChannelImpl.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
public int write(ByteBuffer src, long position) throws IOException { if (src == null) throw new NullPointerException(); if (position < 0) throw new IllegalArgumentException("Negative position"); if (!writable) throw new NonWritableChannelException(); ensureOpen(); if (nd.needsPositionLock()) { synchronized (positionLock) { return writeInternal(src, position); } } else { return writeInternal(src, position); } }
Example #21
Source File: FileChannelImpl.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
public long transferFrom(ReadableByteChannel src, long position, long count) throws IOException { ensureOpen(); if (!src.isOpen()) throw new ClosedChannelException(); if (!writable) throw new NonWritableChannelException(); if ((position < 0) || (count < 0)) throw new IllegalArgumentException(); if (position > size()) return 0; if (src instanceof FileChannelImpl) return transferFromFileChannel((FileChannelImpl)src, position, count); return transferFromArbitraryChannel(src, position, count); }
Example #22
Source File: FileChannelImpl.java From hottub with GNU General Public License v2.0 | 6 votes |
public int write(ByteBuffer src, long position) throws IOException { if (src == null) throw new NullPointerException(); if (position < 0) throw new IllegalArgumentException("Negative position"); if (!writable) throw new NonWritableChannelException(); ensureOpen(); if (nd.needsPositionLock()) { synchronized (positionLock) { return writeInternal(src, position); } } else { return writeInternal(src, position); } }
Example #23
Source File: FileNio.java From dble with GNU General Public License v2.0 | 6 votes |
@Override public synchronized int write(ByteBuffer src) throws IOException { try { int len; if (fileLength < pos + src.remaining()) { int length = (int) (fileLength - pos); int limit = src.limit(); src.limit(length); len = channel.write(src); src.limit(limit); pos += len; return len; } else { len = channel.write(src); pos += len; return len; } } catch (NonWritableChannelException e) { throw new IOException("read only"); } }
Example #24
Source File: FileChannelImpl.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
public int write(ByteBuffer src, long position) throws IOException { if (src == null) throw new NullPointerException(); if (position < 0) throw new IllegalArgumentException("Negative position"); if (!writable) throw new NonWritableChannelException(); ensureOpen(); if (nd.needsPositionLock()) { synchronized (positionLock) { return writeInternal(src, position); } } else { return writeInternal(src, position); } }
Example #25
Source File: FileChannelImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public int write(ByteBuffer src, long position) throws IOException { if (src == null) throw new NullPointerException(); if (position < 0) throw new IllegalArgumentException("Negative position"); if (!writable) throw new NonWritableChannelException(); ensureOpen(); if (nd.needsPositionLock()) { synchronized (positionLock) { return writeInternal(src, position); } } else { return writeInternal(src, position); } }
Example #26
Source File: JMpqEditor.java From JMPQ3 with Apache License 2.0 | 5 votes |
/** * Deletes the specified file out of the mpq once you rebuild the mpq. * * @param name of the file inside the mpq * @throws JMpqException if file is not found or access errors occur */ public void deleteFile(String name) { if (!canWrite) { throw new NonWritableChannelException(); } if (listFile.containsFile(name)) { listFile.removeFile(name); filenameToData.remove(name); } }
Example #27
Source File: IsmReaderTest.java From beam with Apache License 2.0 | 5 votes |
@Test public void testCachedTailSeekableByteChannelThrowsOnWrite() throws Exception { try (SeekableByteChannel channel = new CachedTailSeekableByteChannel(0, new byte[0])) { expectedException.expect(NonWritableChannelException.class); channel.write(ByteBuffer.wrap(new byte[0])); } }
Example #28
Source File: FileChannelTest.java From j2objc with Apache License 2.0 | 5 votes |
/** * @tests java.nio.channels.FileChannel#transferFrom(ReadableByteChannel,long,long) */ public void test_transferFromLReadableByteChannelJJ_NonWritable() throws Exception { readByteChannel = DatagramChannel.open(); try { readOnlyFileChannel.transferFrom(readByteChannel, 0, 0); fail("should throw NonWritableChannelException."); } catch (NonWritableChannelException e) { // expected } }
Example #29
Source File: MemFileChannel.java From jackcess with Apache License 2.0 | 5 votes |
@Override public long transferFrom(ReadableByteChannel src, long position, long count) throws IOException { throw new NonWritableChannelException(); }
Example #30
Source File: FileChannelLockingTest.java From j2objc with Apache License 2.0 | 5 votes |
public void test_tryLock() throws IOException { try { readOnlyChannel.tryLock(); fail("Acquiring a full exclusive lock on a read channel should have thrown an exception."); } catch (NonWritableChannelException ex) { // Expected. } }