当前位置: 首页>>代码示例>>Java>>正文


Java FileChannelImpl.open方法代码示例

本文整理汇总了Java中sun.nio.ch.FileChannelImpl.open方法的典型用法代码示例。如果您正苦于以下问题:Java FileChannelImpl.open方法的具体用法?Java FileChannelImpl.open怎么用?Java FileChannelImpl.open使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sun.nio.ch.FileChannelImpl的用法示例。


在下文中一共展示了FileChannelImpl.open方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: newFileChannel

import sun.nio.ch.FileChannelImpl; //导入方法依赖的package包/类
/**
 * 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);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:35,代码来源:WindowsChannelFactory.java

示例2: getChannel

import sun.nio.ch.FileChannelImpl; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:38,代码来源:FileInputStream.java

示例3: getChannel

import sun.nio.ch.FileChannelImpl; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:38,代码来源:RandomAccessFile.java

示例4: getChannel

import sun.nio.ch.FileChannelImpl; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:39,代码来源:FileOutputStream.java

示例5: getChannel

import sun.nio.ch.FileChannelImpl; //导入方法依赖的package包/类
/**
 * 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.get()) {
                    try {
                        fc.close();
                    } catch (IOException ioe) {
                        throw new InternalError(ioe); // should not happen
                    }
                }
            }
        }
    }
    return fc;
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:36,代码来源:FileInputStream.java

示例6: getChannel

import sun.nio.ch.FileChannelImpl; //导入方法依赖的package包/类
/**
 * 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.get()) {
                    try {
                        fc.close();
                    } catch (IOException ioe) {
                        throw new InternalError(ioe); // should not happen
                    }
                }
            }
        }
    }
    return fc;
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:37,代码来源:FileOutputStream.java

示例7: getChannel

import sun.nio.ch.FileChannelImpl; //导入方法依赖的package包/类
/**
 * Returns the unique {@link java.nio.channels.FileChannel FileChannel}
 * object associated with this file.
 *
 * <p> The {@link java.nio.channels.FileChannel#position()
 * </code>position<code>} 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() {
    synchronized (this) {
        if (channel == null) {
            channel = FileChannelImpl.open(fd, path, true, rw, this);

            /*
             * FileDescriptor could be shared by FileInputStream or
             * FileOutputStream.
             * Ensure that FD is GC'ed only when all the streams/channels
             * are done using it.
             * Increment fd's use count. Invoking the channel's close()
             * method will result in decrementing the use count set for
             * the channel.
             */
            fd.incrementAndGetUseCount();
        }
        return channel;
    }
}
 
开发者ID:ZhaoX,项目名称:jdk-1.7-annotated,代码行数:38,代码来源:RandomAccessFile.java

示例8: getChannel

import sun.nio.ch.FileChannelImpl; //导入方法依赖的package包/类
/**
 * Returns the unique {@link java.nio.channels.FileChannel FileChannel}
 * object associated with this file.
 *
 * <p> The {@link java.nio.channels.FileChannel#position()
 * </code>position<code>} 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() {
    synchronized (this) {
        if (channel == null) {
            channel = FileChannelImpl.open(fd, true, rw, this);

            /*
             * FileDescriptor could be shared by FileInputStream or
             * FileOutputStream.
             * Ensure that FD is GC'ed only when all the streams/channels
             * are done using it.
             * Increment fd's use count. Invoking the channel's close()
             * method will result in decrementing the use count set for
             * the channel.
             */
            fd.incrementAndGetUseCount();
        }
        return channel;
    }
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:38,代码来源:RandomAccessFile.java

示例9: newFileChannel

import sun.nio.ch.FileChannelImpl; //导入方法依赖的package包/类
/**
 * 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);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:31,代码来源:UnixChannelFactory.java

示例10: newFileChannel

import sun.nio.ch.FileChannelImpl; //导入方法依赖的package包/类
/**
 * 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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:31,代码来源:UnixChannelFactory.java

示例11: newFileChannel

import sun.nio.ch.FileChannelImpl; //导入方法依赖的package包/类
/**
 * 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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:35,代码来源:WindowsChannelFactory.java

示例12: getChannel

import sun.nio.ch.FileChannelImpl; //导入方法依赖的package包/类
public FileChannel getChannel(){
    synchronized (this){
        if (channel == null){
            channel = FileChannelImpl.open(fd, path, true, false, this);
        }
        
        return channel;
    }
}
 
开发者ID:cFerg,项目名称:MineJava,代码行数:10,代码来源:FileInputStream.java

示例13: newFileChannel

import sun.nio.ch.FileChannelImpl; //导入方法依赖的package包/类
/**
 * 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);
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:35,代码来源:WindowsChannelFactory.java

示例14: newFileChannel

import sun.nio.ch.FileChannelImpl; //导入方法依赖的package包/类
/**
 * 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);
}
 
开发者ID:aducode,项目名称:openjdk-source-code-learn,代码行数:31,代码来源:UnixChannelFactory.java

示例15: newFileChannel

import sun.nio.ch.FileChannelImpl; //导入方法依赖的package包/类
/**
 * 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);
}
 
开发者ID:alexkasko,项目名称:openjdk-icedtea7,代码行数:32,代码来源:UnixChannelFactory.java


注:本文中的sun.nio.ch.FileChannelImpl.open方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。