sun.nio.ch.FileChannelImpl Java Examples
The following examples show how to use
sun.nio.ch.FileChannelImpl.
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: MappedBufferCleanUtil.java From nuls with MIT License | 6 votes |
public static void clean(final Object buffer) { if (null == buffer) { return; } try { //unmap Method m = FileChannelImpl.class.getDeclaredMethod("unmap", MappedByteBuffer.class); m.setAccessible(true); m.invoke(FileChannelImpl.class, buffer); //Another way of implementation // Method getCleanerMethod = buffer.getClass().getMethod("cleaner", new Class[0]); // getCleanerMethod.setAccessible(true); // sun.misc.Cleaner cleaner = (sun.misc.Cleaner) getCleanerMethod.invoke(buffer, new Object[0]); // cleaner.clean(); // getCleanerMethod.setAccessible(false); } catch (Exception e) { throw new RuntimeException(e); } }
Example #2
Source File: FileInputStream.java From Bytecoder with Apache License 2.0 | 6 votes |
/** * Returns the unique {@link java.nio.channels.FileChannel FileChannel} * object associated with this file input stream. * * <p> The initial {@link java.nio.channels.FileChannel#position() * position} of the returned channel will be equal to the * number of bytes read from the file so far. Reading bytes from this * stream will increment the channel's position. Changing the channel's * position, either explicitly or by reading, will change this stream's * file position. * * @return the file channel associated with this file input stream * * @since 1.4 * @spec JSR-51 */ public FileChannel getChannel() { FileChannel fc = this.channel; if (fc == null) { synchronized (this) { fc = this.channel; if (fc == null) { this.channel = fc = FileChannelImpl.open(fd, path, true, false, false, this); if (closed) { try { // possible race with close(), benign since // FileChannel.close is final and idempotent fc.close(); } catch (IOException ioe) { throw new InternalError(ioe); // should not happen } } } } } return fc; }
Example #3
Source File: RandomAccessFile.java From Bytecoder with Apache License 2.0 | 6 votes |
/** * Returns the unique {@link java.nio.channels.FileChannel FileChannel} * object associated with this file. * * <p> The {@link java.nio.channels.FileChannel#position() * position} of the returned channel will always be equal to * this object's file-pointer offset as returned by the {@link * #getFilePointer getFilePointer} method. Changing this object's * file-pointer offset, whether explicitly or by reading or writing bytes, * will change the position of the channel, and vice versa. Changing the * file's length via this object will change the length seen via the file * channel, and vice versa. * * @return the file channel associated with this file * * @since 1.4 * @spec JSR-51 */ public final FileChannel getChannel() { FileChannel fc = this.channel; if (fc == null) { synchronized (this) { fc = this.channel; if (fc == null) { this.channel = fc = FileChannelImpl.open(fd, path, true, rw, false, this); if (closed) { try { fc.close(); } catch (IOException ioe) { throw new InternalError(ioe); // should not happen } } } } } return fc; }
Example #4
Source File: FileOutputStream.java From Bytecoder with Apache License 2.0 | 6 votes |
/** * Returns the unique {@link java.nio.channels.FileChannel FileChannel} * object associated with this file output stream. * * <p> The initial {@link java.nio.channels.FileChannel#position() * position} of the returned channel will be equal to the * number of bytes written to the file so far unless this stream is in * append mode, in which case it will be equal to the size of the file. * Writing bytes to this stream will increment the channel's position * accordingly. Changing the channel's position, either explicitly or by * writing, will change this stream's file position. * * @return the file channel associated with this file output stream * * @since 1.4 * @spec JSR-51 */ public FileChannel getChannel() { FileChannel fc = this.channel; if (fc == null) { synchronized (this) { fc = this.channel; if (fc == null) { this.channel = fc = FileChannelImpl.open(fd, path, false, true, false, this); if (closed) { try { // possible race with close(), benign since // FileChannel.close is final and idempotent fc.close(); } catch (IOException ioe) { throw new InternalError(ioe); // should not happen } } } } } return fc; }
Example #5
Source File: FileInputStream.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Returns the unique {@link java.nio.channels.FileChannel FileChannel} * object associated with this file input stream. * * <p> The initial {@link java.nio.channels.FileChannel#position() * position} of the returned channel will be equal to the * number of bytes read from the file so far. Reading bytes from this * stream will increment the channel's position. Changing the channel's * position, either explicitly or by reading, will change this stream's * file position. * * @return the file channel associated with this file input stream * * @since 1.4 * @spec JSR-51 */ public FileChannel getChannel() { FileChannel fc = this.channel; if (fc == null) { synchronized (this) { fc = this.channel; if (fc == null) { this.channel = fc = FileChannelImpl.open(fd, path, true, false, this); if (closed) { try { // possible race with close(), benign since // FileChannel.close is final and idempotent fc.close(); } catch (IOException ioe) { throw new InternalError(ioe); // should not happen } } } } } return fc; }
Example #6
Source File: RandomAccessFile.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Returns the unique {@link java.nio.channels.FileChannel FileChannel} * object associated with this file. * * <p> The {@link java.nio.channels.FileChannel#position() * position} of the returned channel will always be equal to * this object's file-pointer offset as returned by the {@link * #getFilePointer getFilePointer} method. Changing this object's * file-pointer offset, whether explicitly or by reading or writing bytes, * will change the position of the channel, and vice versa. Changing the * file's length via this object will change the length seen via the file * channel, and vice versa. * * @return the file channel associated with this file * * @since 1.4 * @spec JSR-51 */ public final FileChannel getChannel() { FileChannel fc = this.channel; if (fc == null) { synchronized (this) { fc = this.channel; if (fc == null) { this.channel = fc = FileChannelImpl.open(fd, path, true, rw, this); if (closed.get()) { try { fc.close(); } catch (IOException ioe) { throw new InternalError(ioe); // should not happen } } } } } return fc; }
Example #7
Source File: FileOutputStream.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Returns the unique {@link java.nio.channels.FileChannel FileChannel} * object associated with this file output stream. * * <p> The initial {@link java.nio.channels.FileChannel#position() * position} of the returned channel will be equal to the * number of bytes written to the file so far unless this stream is in * append mode, in which case it will be equal to the size of the file. * Writing bytes to this stream will increment the channel's position * accordingly. Changing the channel's position, either explicitly or by * writing, will change this stream's file position. * * @return the file channel associated with this file output stream * * @since 1.4 * @spec JSR-51 */ public FileChannel getChannel() { FileChannel fc = this.channel; if (fc == null) { synchronized (this) { fc = this.channel; if (fc == null) { this.channel = fc = FileChannelImpl.open(fd, path, false, true, this); if (closed) { try { // possible race with close(), benign since // FileChannel.close is final and idempotent fc.close(); } catch (IOException ioe) { throw new InternalError(ioe); // should not happen } } } } } return fc; }
Example #8
Source File: WindowsChannelFactory.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Open/creates file, returning FileChannel to access the file * * @param pathForWindows * The path of the file to open/create * @param pathToCheck * The path used for permission checks (if security manager) */ static FileChannel newFileChannel(String pathForWindows, String pathToCheck, Set<? extends OpenOption> options, long pSecurityDescriptor) throws WindowsException { Flags flags = Flags.toFlags(options); // default is reading; append => writing if (!flags.read && !flags.write) { if (flags.append) { flags.write = true; } else { flags.read = true; } } // validation if (flags.read && flags.append) throw new IllegalArgumentException("READ + APPEND not allowed"); if (flags.append && flags.truncateExisting) throw new IllegalArgumentException("APPEND + TRUNCATE_EXISTING not allowed"); FileDescriptor fdObj = open(pathForWindows, pathToCheck, flags, pSecurityDescriptor); return FileChannelImpl.open(fdObj, pathForWindows, flags.read, flags.write, flags.append, null); }
Example #9
Source File: UnixChannelFactory.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Constructs a file channel by opening a file using a dfd/path pair */ static FileChannel newFileChannel(int dfd, UnixPath path, String pathForPermissionCheck, Set<? extends OpenOption> options, int mode) throws UnixException { Flags flags = Flags.toFlags(options); // default is reading; append => writing if (!flags.read && !flags.write) { if (flags.append) { flags.write = true; } else { flags.read = true; } } // validation if (flags.read && flags.append) throw new IllegalArgumentException("READ + APPEND not allowed"); if (flags.append && flags.truncateExisting) throw new IllegalArgumentException("APPEND + TRUNCATE_EXISTING not allowed"); FileDescriptor fdObj = open(dfd, path, pathForPermissionCheck, flags, mode); return FileChannelImpl.open(fdObj, path.toString(), flags.read, flags.write, flags.append, null); }
Example #10
Source File: UnixChannelFactory.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Constructs a file channel by opening a file using a dfd/path pair */ static FileChannel newFileChannel(int dfd, UnixPath path, String pathForPermissionCheck, Set<? extends OpenOption> options, int mode) throws UnixException { Flags flags = Flags.toFlags(options); // default is reading; append => writing if (!flags.read && !flags.write) { if (flags.append) { flags.write = true; } else { flags.read = true; } } // validation if (flags.read && flags.append) throw new IllegalArgumentException("READ + APPEND not allowed"); if (flags.append && flags.truncateExisting) throw new IllegalArgumentException("APPEND + TRUNCATE_EXISTING not allowed"); FileDescriptor fdObj = open(dfd, path, pathForPermissionCheck, flags, mode); return FileChannelImpl.open(fdObj, flags.read, flags.write, flags.append, null); }
Example #11
Source File: UnixChannelFactory.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Constructs a file channel by opening a file using a dfd/path pair */ static FileChannel newFileChannel(int dfd, UnixPath path, String pathForPermissionCheck, Set<? extends OpenOption> options, int mode) throws UnixException { Flags flags = Flags.toFlags(options); // default is reading; append => writing if (!flags.read && !flags.write) { if (flags.append) { flags.write = true; } else { flags.read = true; } } // validation if (flags.read && flags.append) throw new IllegalArgumentException("READ + APPEND not allowed"); if (flags.append && flags.truncateExisting) throw new IllegalArgumentException("APPEND + TRUNCATE_EXISTING not allowed"); FileDescriptor fdObj = open(dfd, path, pathForPermissionCheck, flags, mode); return FileChannelImpl.open(fdObj, path.toString(), flags.read, flags.write, flags.append, null); }
Example #12
Source File: UnixChannelFactory.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
/** * Constructs a file channel by opening a file using a dfd/path pair */ static FileChannel newFileChannel(int dfd, UnixPath path, String pathForPermissionCheck, Set<? extends OpenOption> options, int mode) throws UnixException { Flags flags = Flags.toFlags(options); // default is reading; append => writing if (!flags.read && !flags.write) { if (flags.append) { flags.write = true; } else { flags.read = true; } } // validation if (flags.read && flags.append) throw new IllegalArgumentException("READ + APPEND not allowed"); if (flags.append && flags.truncateExisting) throw new IllegalArgumentException("APPEND + TRUNCATE_EXISTING not allowed"); FileDescriptor fdObj = open(dfd, path, pathForPermissionCheck, flags, mode); return FileChannelImpl.open(fdObj, path.toString(), flags.read, flags.write, flags.append, null); }
Example #13
Source File: WindowsChannelFactory.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Open/creates file, returning FileChannel to access the file * * @param pathForWindows * The path of the file to open/create * @param pathToCheck * The path used for permission checks (if security manager) */ static FileChannel newFileChannel(String pathForWindows, String pathToCheck, Set<? extends OpenOption> options, long pSecurityDescriptor) throws WindowsException { Flags flags = Flags.toFlags(options); // default is reading; append => writing if (!flags.read && !flags.write) { if (flags.append) { flags.write = true; } else { flags.read = true; } } // validation if (flags.read && flags.append) throw new IllegalArgumentException("READ + APPEND not allowed"); if (flags.append && flags.truncateExisting) throw new IllegalArgumentException("APPEND + TRUNCATE_EXISTING not allowed"); FileDescriptor fdObj = open(pathForWindows, pathToCheck, flags, pSecurityDescriptor); return FileChannelImpl.open(fdObj, pathForWindows, flags.read, flags.write, flags.append, null); }
Example #14
Source File: UnixChannelFactory.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Constructs a file channel by opening a file using a dfd/path pair */ static FileChannel newFileChannel(int dfd, UnixPath path, String pathForPermissionCheck, Set<? extends OpenOption> options, int mode) throws UnixException { Flags flags = Flags.toFlags(options); // default is reading; append => writing if (!flags.read && !flags.write) { if (flags.append) { flags.write = true; } else { flags.read = true; } } // validation if (flags.read && flags.append) throw new IllegalArgumentException("READ + APPEND not allowed"); if (flags.append && flags.truncateExisting) throw new IllegalArgumentException("APPEND + TRUNCATE_EXISTING not allowed"); FileDescriptor fdObj = open(dfd, path, pathForPermissionCheck, flags, mode); return FileChannelImpl.open(fdObj, path.toString(), flags.read, flags.write, flags.append, null); }
Example #15
Source File: WindowsChannelFactory.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** * Open/creates file, returning FileChannel to access the file * * @param pathForWindows * The path of the file to open/create * @param pathToCheck * The path used for permission checks (if security manager) */ static FileChannel newFileChannel(String pathForWindows, String pathToCheck, Set<? extends OpenOption> options, long pSecurityDescriptor) throws WindowsException { Flags flags = Flags.toFlags(options); // default is reading; append => writing if (!flags.read && !flags.write) { if (flags.append) { flags.write = true; } else { flags.read = true; } } // validation if (flags.read && flags.append) throw new IllegalArgumentException("READ + APPEND not allowed"); if (flags.append && flags.truncateExisting) throw new IllegalArgumentException("APPEND + TRUNCATE_EXISTING not allowed"); FileDescriptor fdObj = open(pathForWindows, pathToCheck, flags, pSecurityDescriptor); return FileChannelImpl.open(fdObj, pathForWindows, flags.read, flags.write, flags.append, null); }
Example #16
Source File: WindowsChannelFactory.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Open/creates file, returning FileChannel to access the file * * @param pathForWindows * The path of the file to open/create * @param pathToCheck * The path used for permission checks (if security manager) */ static FileChannel newFileChannel(String pathForWindows, String pathToCheck, Set<? extends OpenOption> options, long pSecurityDescriptor) throws WindowsException { Flags flags = Flags.toFlags(options); // default is reading; append => writing if (!flags.read && !flags.write) { if (flags.append) { flags.write = true; } else { flags.read = true; } } // validation if (flags.read && flags.append) throw new IllegalArgumentException("READ + APPEND not allowed"); if (flags.append && flags.truncateExisting) throw new IllegalArgumentException("APPEND + TRUNCATE_EXISTING not allowed"); FileDescriptor fdObj = open(pathForWindows, pathToCheck, flags, pSecurityDescriptor); return FileChannelImpl.open(fdObj, pathForWindows, flags.read, flags.write, flags.append, null); }
Example #17
Source File: UnixChannelFactory.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** * Constructs a file channel by opening a file using a dfd/path pair */ static FileChannel newFileChannel(int dfd, UnixPath path, String pathForPermissionCheck, Set<? extends OpenOption> options, int mode) throws UnixException { Flags flags = Flags.toFlags(options); // default is reading; append => writing if (!flags.read && !flags.write) { if (flags.append) { flags.write = true; } else { flags.read = true; } } // validation if (flags.read && flags.append) throw new IllegalArgumentException("READ + APPEND not allowed"); if (flags.append && flags.truncateExisting) throw new IllegalArgumentException("APPEND + TRUNCATE_EXISTING not allowed"); FileDescriptor fdObj = open(dfd, path, pathForPermissionCheck, flags, mode); return FileChannelImpl.open(fdObj, path.toString(), flags.read, flags.write, flags.append, null); }
Example #18
Source File: WindowsChannelFactory.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Open/creates file, returning FileChannel to access the file * * @param pathForWindows * The path of the file to open/create * @param pathToCheck * The path used for permission checks (if security manager) */ static FileChannel newFileChannel(String pathForWindows, String pathToCheck, Set<? extends OpenOption> options, long pSecurityDescriptor) throws WindowsException { Flags flags = Flags.toFlags(options); // default is reading; append => writing if (!flags.read && !flags.write) { if (flags.append) { flags.write = true; } else { flags.read = true; } } // validation if (flags.read && flags.append) throw new IllegalArgumentException("READ + APPEND not allowed"); if (flags.append && flags.truncateExisting) throw new IllegalArgumentException("APPEND + TRUNCATE_EXISTING not allowed"); FileDescriptor fdObj = open(pathForWindows, pathToCheck, flags, pSecurityDescriptor); return FileChannelImpl.open(fdObj, pathForWindows, flags.read, flags.write, flags.append, null); }
Example #19
Source File: UnixChannelFactory.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Constructs a file channel by opening a file using a dfd/path pair */ static FileChannel newFileChannel(int dfd, UnixPath path, String pathForPermissionCheck, Set<? extends OpenOption> options, int mode) throws UnixException { Flags flags = Flags.toFlags(options); // default is reading; append => writing if (!flags.read && !flags.write) { if (flags.append) { flags.write = true; } else { flags.read = true; } } // validation if (flags.read && flags.append) throw new IllegalArgumentException("READ + APPEND not allowed"); if (flags.append && flags.truncateExisting) throw new IllegalArgumentException("APPEND + TRUNCATE_EXISTING not allowed"); FileDescriptor fdObj = open(dfd, path, pathForPermissionCheck, flags, mode); return FileChannelImpl.open(fdObj, path.toString(), flags.read, flags.write, flags.append, null); }
Example #20
Source File: UnixChannelFactory.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Constructs a file channel by opening a file using a dfd/path pair */ static FileChannel newFileChannel(int dfd, UnixPath path, String pathForPermissionCheck, Set<? extends OpenOption> options, int mode) throws UnixException { Flags flags = Flags.toFlags(options); // default is reading; append => writing if (!flags.read && !flags.write) { if (flags.append) { flags.write = true; } else { flags.read = true; } } // validation if (flags.read && flags.append) throw new IllegalArgumentException("READ + APPEND not allowed"); if (flags.append && flags.truncateExisting) throw new IllegalArgumentException("APPEND + TRUNCATE_EXISTING not allowed"); FileDescriptor fdObj = open(dfd, path, pathForPermissionCheck, flags, mode); return FileChannelImpl.open(fdObj, path.toString(), flags.read, flags.write, null); }
Example #21
Source File: WindowsChannelFactory.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Open/creates file, returning FileChannel to access the file * * @param pathForWindows * The path of the file to open/create * @param pathToCheck * The path used for permission checks (if security manager) */ static FileChannel newFileChannel(String pathForWindows, String pathToCheck, Set<? extends OpenOption> options, long pSecurityDescriptor) throws WindowsException { Flags flags = Flags.toFlags(options); // default is reading; append => writing if (!flags.read && !flags.write) { if (flags.append) { flags.write = true; } else { flags.read = true; } } // validation if (flags.read && flags.append) throw new IllegalArgumentException("READ + APPEND not allowed"); if (flags.append && flags.truncateExisting) throw new IllegalArgumentException("APPEND + TRUNCATE_EXISTING not allowed"); FileDescriptor fdObj = open(pathForWindows, pathToCheck, flags, pSecurityDescriptor); return FileChannelImpl.open(fdObj, pathForWindows, flags.read, flags.write, null); }
Example #22
Source File: WindowsChannelFactory.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Open/creates file, returning FileChannel to access the file * * @param pathForWindows * The path of the file to open/create * @param pathToCheck * The path used for permission checks (if security manager) */ static FileChannel newFileChannel(String pathForWindows, String pathToCheck, Set<? extends OpenOption> options, long pSecurityDescriptor) throws WindowsException { Flags flags = Flags.toFlags(options); // default is reading; append => writing if (!flags.read && !flags.write) { if (flags.append) { flags.write = true; } else { flags.read = true; } } // validation if (flags.read && flags.append) throw new IllegalArgumentException("READ + APPEND not allowed"); if (flags.append && flags.truncateExisting) throw new IllegalArgumentException("APPEND + TRUNCATE_EXISTING not allowed"); FileDescriptor fdObj = open(pathForWindows, pathToCheck, flags, pSecurityDescriptor); return FileChannelImpl.open(fdObj, pathForWindows, flags.read, flags.write, flags.append, null); }
Example #23
Source File: UnixChannelFactory.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Constructs a file channel by opening a file using a dfd/path pair */ static FileChannel newFileChannel(int dfd, UnixPath path, String pathForPermissionCheck, Set<? extends OpenOption> options, int mode) throws UnixException { Flags flags = Flags.toFlags(options); // default is reading; append => writing if (!flags.read && !flags.write) { if (flags.append) { flags.write = true; } else { flags.read = true; } } // validation if (flags.read && flags.append) throw new IllegalArgumentException("READ + APPEND not allowed"); if (flags.append && flags.truncateExisting) throw new IllegalArgumentException("APPEND + TRUNCATE_EXISTING not allowed"); FileDescriptor fdObj = open(dfd, path, pathForPermissionCheck, flags, mode); return FileChannelImpl.open(fdObj, path.toString(), flags.read, flags.write, flags.append, null); }
Example #24
Source File: UnixChannelFactory.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Constructs a file channel by opening a file using a dfd/path pair */ static FileChannel newFileChannel(int dfd, UnixPath path, String pathForPermissionCheck, Set<? extends OpenOption> options, int mode) throws UnixException { Flags flags = Flags.toFlags(options); // default is reading; append => writing if (!flags.read && !flags.write) { if (flags.append) { flags.write = true; } else { flags.read = true; } } // validation if (flags.read && flags.append) throw new IllegalArgumentException("READ + APPEND not allowed"); if (flags.append && flags.truncateExisting) throw new IllegalArgumentException("APPEND + TRUNCATE_EXISTING not allowed"); FileDescriptor fdObj = open(dfd, path, pathForPermissionCheck, flags, mode); return FileChannelImpl.open(fdObj, path.toString(), flags.read, flags.write, flags.append, null); }
Example #25
Source File: WindowsChannelFactory.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * Open/creates file, returning FileChannel to access the file * * @param pathForWindows * The path of the file to open/create * @param pathToCheck * The path used for permission checks (if security manager) */ static FileChannel newFileChannel(String pathForWindows, String pathToCheck, Set<? extends OpenOption> options, long pSecurityDescriptor) throws WindowsException { Flags flags = Flags.toFlags(options); // default is reading; append => writing if (!flags.read && !flags.write) { if (flags.append) { flags.write = true; } else { flags.read = true; } } // validation if (flags.read && flags.append) throw new IllegalArgumentException("READ + APPEND not allowed"); if (flags.append && flags.truncateExisting) throw new IllegalArgumentException("APPEND + TRUNCATE_EXISTING not allowed"); FileDescriptor fdObj = open(pathForWindows, pathToCheck, flags, pSecurityDescriptor); return FileChannelImpl.open(fdObj, flags.read, flags.write, flags.append, null); }
Example #26
Source File: UnixChannelFactory.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * Constructs a file channel by opening a file using a dfd/path pair */ static FileChannel newFileChannel(int dfd, UnixPath path, String pathForPermissionCheck, Set<? extends OpenOption> options, int mode) throws UnixException { Flags flags = Flags.toFlags(options); // default is reading; append => writing if (!flags.read && !flags.write) { if (flags.append) { flags.write = true; } else { flags.read = true; } } // validation if (flags.read && flags.append) throw new IllegalArgumentException("READ + APPEND not allowed"); if (flags.append && flags.truncateExisting) throw new IllegalArgumentException("APPEND + TRUNCATE_EXISTING not allowed"); FileDescriptor fdObj = open(dfd, path, pathForPermissionCheck, flags, mode); return FileChannelImpl.open(fdObj, flags.read, flags.write, flags.append, null); }
Example #27
Source File: WindowsChannelFactory.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Open/creates file, returning FileChannel to access the file * * @param pathForWindows * The path of the file to open/create * @param pathToCheck * The path used for permission checks (if security manager) */ static FileChannel newFileChannel(String pathForWindows, String pathToCheck, Set<? extends OpenOption> options, long pSecurityDescriptor) throws WindowsException { Flags flags = Flags.toFlags(options); // default is reading; append => writing if (!flags.read && !flags.write) { if (flags.append) { flags.write = true; } else { flags.read = true; } } // validation if (flags.read && flags.append) throw new IllegalArgumentException("READ + APPEND not allowed"); if (flags.append && flags.truncateExisting) throw new IllegalArgumentException("APPEND + TRUNCATE_EXISTING not allowed"); FileDescriptor fdObj = open(pathForWindows, pathToCheck, flags, pSecurityDescriptor); return FileChannelImpl.open(fdObj, flags.read, flags.write, flags.append, null); }
Example #28
Source File: WindowsChannelFactory.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
/** * Open/creates file, returning FileChannel to access the file * * @param pathForWindows * The path of the file to open/create * @param pathToCheck * The path used for permission checks (if security manager) */ static FileChannel newFileChannel(String pathForWindows, String pathToCheck, Set<? extends OpenOption> options, long pSecurityDescriptor) throws WindowsException { Flags flags = Flags.toFlags(options); // default is reading; append => writing if (!flags.read && !flags.write) { if (flags.append) { flags.write = true; } else { flags.read = true; } } // validation if (flags.read && flags.append) throw new IllegalArgumentException("READ + APPEND not allowed"); if (flags.append && flags.truncateExisting) throw new IllegalArgumentException("APPEND + TRUNCATE_EXISTING not allowed"); FileDescriptor fdObj = open(pathForWindows, pathToCheck, flags, pSecurityDescriptor); return FileChannelImpl.open(fdObj, pathForWindows, flags.read, flags.write, flags.append, null); }
Example #29
Source File: UnixChannelFactory.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
/** * Constructs a file channel from an existing (open) file descriptor */ static FileChannel newFileChannel(int fd, String path, boolean reading, boolean writing) { FileDescriptor fdObj = new FileDescriptor(); fdAccess.set(fdObj, fd); return FileChannelImpl.open(fdObj, path, reading, writing, null); }
Example #30
Source File: UnixChannelFactory.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
/** * Constructs a file channel from an existing (open) file descriptor */ static FileChannel newFileChannel(int fd, boolean reading, boolean writing) { FileDescriptor fdObj = new FileDescriptor(); fdAccess.set(fdObj, fd); return FileChannelImpl.open(fdObj, reading, writing, null); }