/** * Write the bytes in the specified byte list to the associated channel. * * @param buffer the byte list containing the bytes to be written * @return the number of bytes actually written * @throws java.io.IOException if there is an exception during IO * @throws org.jruby.util.io.BadDescriptorException if the associated * channel is already closed */ public int internalWrite(ByteBuffer buffer) throws IOException, BadDescriptorException { checkOpen(); // TODO: It would be nice to throw a better error for this if (!isWritable()) { throw new BadDescriptorException(); } WritableByteChannel writeChannel = (WritableByteChannel)channel; // if appendable, we always seek to the end before writing if (isSeekable() && originalModes.isAppendable()) { // if already in append mode, we don't do our own seeking if (!isInAppendMode) { FileChannel fileChannel = (FileChannel)channel; fileChannel.position(fileChannel.size()); } } return writeChannel.write(buffer); }
/** * Write the bytes in the specified byte list to the associated channel. * * @param buffer the byte list containing the bytes to be written * @return the number of bytes actually written * @throws java.io.IOException if there is an exception during IO * @throws org.jruby.util.io.BadDescriptorException if the associated * channel is already closed */ public int internalWrite(ByteBuffer buffer) throws IOException, BadDescriptorException { checkOpen(); // TODO: It would be nice to throw a better error for this if (!isWritable()) { throw new BadDescriptorException(); } WritableByteChannel writeChannel = (WritableByteChannel)channel; // if appendable, we always seek to the end before writing if (isSeekable() && originalModes.isAppendable()) { // if already in append mode, we don't do our own seeking if (!isInAppendMode) { FileChannel fileChannel = (FileChannel)channel; fileChannel.position(fileChannel.size()); } } return writeChannel.write(buffer); }
/** * Write the bytes in the specified byte list to the associated channel. * * @param buffer the byte list containing the bytes to be written * @return the number of bytes actually written * @throws java.io.IOException if there is an exception during IO * @throws org.jruby.util.io.BadDescriptorException if the associated * channel is already closed */ public int internalWrite(ByteBuffer buffer) throws IOException, BadDescriptorException { checkOpen(); // TODO: It would be nice to throw a better error for this if (!isWritable()) { throw new BadDescriptorException(); } WritableByteChannel writeChannel = (WritableByteChannel)channel; // if appendable, we always seek to the end before writing if (isSeekable() && originalModes.isAppendable()) { // if already in append mode, we don't do our own seeking if (!isInAppendMode) { SeekableByteChannel fileChannel = (SeekableByteChannel) channel; fileChannel.position(fileChannel.size()); } } return writeChannel.write(buffer); }
/** * Write the bytes in the specified byte list to the associated channel. * * @param buffer the byte list containing the bytes to be written * @return the number of bytes actually written * @throws java.io.IOException if there is an exception during IO * @throws org.jruby.util.io.BadDescriptorException if the associated * channel is already closed */ public int internalWrite(ByteBuffer buffer) throws IOException, BadDescriptorException { checkOpen(); // TODO: It would be nice to throw a better error for this if (!isWritable()) { throw new BadDescriptorException(); } WritableByteChannel writeChannel = (WritableByteChannel)channel; // if appendable, we always seek to the end before writing if (isSeekable() && originalModes.isAppendable()) { // if already in append mode, we don't do our own seeking if (!isInAppendMode) { SeekableByteChannel fileChannel = (SeekableByteChannel) channel; fileChannel.position(fileChannel.size()); } } return writeChannel.write(buffer); }
if (!writeStream.getDescriptor().isWritable()) { myOpenFile.checkClosed(runtime);
if (!writeStream.getDescriptor().isWritable()) { myOpenFile.checkClosed(runtime);