jdk/src/share/classes/java/io/FileOutputStream.java
author coffeys
Tue, 13 Sep 2011 11:21:51 +0100
changeset 10586 6e20ecfec8ed
parent 9035 1255eb81cc2f
child 11017 353f81426721
permissions -rw-r--r--
7082769: FileInputStream/FileOutputStream/RandomAccessFile allow file descriptor be closed when still in use Reviewed-by: alanb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
9035
1255eb81cc2f 7033660: Update copyright year to 2011 on any files changed in 2011
ohair
parents: 8158
diff changeset
     2
 * Copyright (c) 1994, 2011, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.io;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.nio.channels.FileChannel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import sun.nio.ch.FileChannelImpl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * A file output stream is an output stream for writing data to a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * <code>File</code> or to a <code>FileDescriptor</code>. Whether or not
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * a file is available or may be created depends upon the underlying
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * platform.  Some platforms, in particular, allow a file to be opened
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * for writing by only one <tt>FileOutputStream</tt> (or other
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * file-writing object) at a time.  In such situations the constructors in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * this class will fail if the file involved is already open.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * <p><code>FileOutputStream</code> is meant for writing streams of raw bytes
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * such as image data. For writing streams of characters, consider using
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * <code>FileWriter</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * @author  Arthur van Hoff
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * @see     java.io.File
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * @see     java.io.FileDescriptor
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * @see     java.io.FileInputStream
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7816
diff changeset
    49
 * @see     java.nio.file.Files#newOutputStream
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * @since   JDK1.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
public
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
class FileOutputStream extends OutputStream
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    /**
46
ddf5deb2a633 6631437: File{In,Out}putStream minor improvements to spec and stylistic improvements to code
martin
parents: 2
diff changeset
    56
     * The system dependent file descriptor.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
     */
46
ddf5deb2a633 6631437: File{In,Out}putStream minor improvements to spec and stylistic improvements to code
martin
parents: 2
diff changeset
    58
    private final FileDescriptor fd;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
7515
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
    60
    /**
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
    61
     * True if the file is opened for append.
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
    62
     */
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
    63
    private final boolean append;
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
    64
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
    65
    /**
10586
6e20ecfec8ed 7082769: FileInputStream/FileOutputStream/RandomAccessFile allow file descriptor be closed when still in use
coffeys
parents: 9035
diff changeset
    66
     * The associated channel, initialized lazily.
7515
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
    67
     */
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
    68
    private FileChannel channel;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
46
ddf5deb2a633 6631437: File{In,Out}putStream minor improvements to spec and stylistic improvements to code
martin
parents: 2
diff changeset
    70
    private final Object closeLock = new Object();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    private volatile boolean closed = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    /**
46
ddf5deb2a633 6631437: File{In,Out}putStream minor improvements to spec and stylistic improvements to code
martin
parents: 2
diff changeset
    74
     * Creates a file output stream to write to the file with the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * specified name. A new <code>FileDescriptor</code> object is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * created to represent this file connection.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * First, if there is a security manager, its <code>checkWrite</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     * method is called with <code>name</code> as its argument.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * If the file exists but is a directory rather than a regular file, does
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * not exist but cannot be created, or cannot be opened for any other
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * reason then a <code>FileNotFoundException</code> is thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * @param      name   the system-dependent filename
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * @exception  FileNotFoundException  if the file exists but is a directory
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     *                   rather than a regular file, does not exist but cannot
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     *                   be created, or cannot be opened for any other reason
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * @exception  SecurityException  if a security manager exists and its
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     *               <code>checkWrite</code> method denies write access
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     *               to the file.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * @see        java.lang.SecurityManager#checkWrite(java.lang.String)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    public FileOutputStream(String name) throws FileNotFoundException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        this(name != null ? new File(name) : null, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    /**
46
ddf5deb2a633 6631437: File{In,Out}putStream minor improvements to spec and stylistic improvements to code
martin
parents: 2
diff changeset
    99
     * Creates a file output stream to write to the file with the specified
ddf5deb2a633 6631437: File{In,Out}putStream minor improvements to spec and stylistic improvements to code
martin
parents: 2
diff changeset
   100
     * name.  If the second argument is <code>true</code>, then
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * bytes will be written to the end of the file rather than the beginning.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * A new <code>FileDescriptor</code> object is created to represent this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * file connection.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * First, if there is a security manager, its <code>checkWrite</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * method is called with <code>name</code> as its argument.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * If the file exists but is a directory rather than a regular file, does
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * not exist but cannot be created, or cannot be opened for any other
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * reason then a <code>FileNotFoundException</code> is thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * @param     name        the system-dependent file name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * @param     append      if <code>true</code>, then bytes will be written
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     *                   to the end of the file rather than the beginning
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * @exception  FileNotFoundException  if the file exists but is a directory
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     *                   rather than a regular file, does not exist but cannot
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     *                   be created, or cannot be opened for any other reason.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * @exception  SecurityException  if a security manager exists and its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     *               <code>checkWrite</code> method denies write access
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     *               to the file.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * @see        java.lang.SecurityManager#checkWrite(java.lang.String)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * @since     JDK1.1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    public FileOutputStream(String name, boolean append)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        throws FileNotFoundException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        this(name != null ? new File(name) : null, append);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * Creates a file output stream to write to the file represented by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * the specified <code>File</code> object. A new
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * <code>FileDescriptor</code> object is created to represent this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * file connection.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * First, if there is a security manager, its <code>checkWrite</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * method is called with the path represented by the <code>file</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * argument as its argument.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * If the file exists but is a directory rather than a regular file, does
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     * not exist but cannot be created, or cannot be opened for any other
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     * reason then a <code>FileNotFoundException</code> is thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * @param      file               the file to be opened for writing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * @exception  FileNotFoundException  if the file exists but is a directory
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     *                   rather than a regular file, does not exist but cannot
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     *                   be created, or cannot be opened for any other reason
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * @exception  SecurityException  if a security manager exists and its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     *               <code>checkWrite</code> method denies write access
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     *               to the file.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * @see        java.io.File#getPath()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * @see        java.lang.SecurityException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * @see        java.lang.SecurityManager#checkWrite(java.lang.String)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    public FileOutputStream(File file) throws FileNotFoundException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        this(file, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * Creates a file output stream to write to the file represented by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * the specified <code>File</code> object. If the second argument is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * <code>true</code>, then bytes will be written to the end of the file
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * rather than the beginning. A new <code>FileDescriptor</code> object is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     * created to represent this file connection.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * First, if there is a security manager, its <code>checkWrite</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     * method is called with the path represented by the <code>file</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     * argument as its argument.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * If the file exists but is a directory rather than a regular file, does
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * not exist but cannot be created, or cannot be opened for any other
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     * reason then a <code>FileNotFoundException</code> is thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     * @param      file               the file to be opened for writing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * @param     append      if <code>true</code>, then bytes will be written
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     *                   to the end of the file rather than the beginning
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * @exception  FileNotFoundException  if the file exists but is a directory
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     *                   rather than a regular file, does not exist but cannot
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     *                   be created, or cannot be opened for any other reason
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * @exception  SecurityException  if a security manager exists and its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     *               <code>checkWrite</code> method denies write access
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     *               to the file.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * @see        java.io.File#getPath()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * @see        java.lang.SecurityException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * @see        java.lang.SecurityManager#checkWrite(java.lang.String)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    public FileOutputStream(File file, boolean append)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        throws FileNotFoundException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        String name = (file != null ? file.getPath() : null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        SecurityManager security = System.getSecurityManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        if (security != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
            security.checkWrite(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        if (name == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
            throw new NullPointerException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        }
7515
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   199
        this.fd = new FileDescriptor();
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   200
        this.append = append;
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   201
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        fd.incrementAndGetUseCount();
47
c8f0e41aea68 6631352: File{OutputStream,Writer} should implement atomic append mode using FILE_APPEND_DATA (win)
martin
parents: 46
diff changeset
   203
        open(name, append);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    /**
46
ddf5deb2a633 6631437: File{In,Out}putStream minor improvements to spec and stylistic improvements to code
martin
parents: 2
diff changeset
   207
     * Creates a file output stream to write to the specified file
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * descriptor, which represents an existing connection to an actual
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * file in the file system.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     * First, if there is a security manager, its <code>checkWrite</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * method is called with the file descriptor <code>fdObj</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * argument as its argument.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     * If <code>fdObj</code> is null then a <code>NullPointerException</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * is thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     * This constructor does not throw an exception if <code>fdObj</code>
46
ddf5deb2a633 6631437: File{In,Out}putStream minor improvements to spec and stylistic improvements to code
martin
parents: 2
diff changeset
   219
     * is {@link java.io.FileDescriptor#valid() invalid}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     * However, if the methods are invoked on the resulting stream to attempt
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     * I/O on the stream, an <code>IOException</code> is thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     * @param      fdObj   the file descriptor to be opened for writing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     * @exception  SecurityException  if a security manager exists and its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     *               <code>checkWrite</code> method denies
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     *               write access to the file descriptor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * @see        java.lang.SecurityManager#checkWrite(java.io.FileDescriptor)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    public FileOutputStream(FileDescriptor fdObj) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        SecurityManager security = System.getSecurityManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        if (fdObj == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
            throw new NullPointerException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        if (security != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
            security.checkWrite(fdObj);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        }
7515
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   237
        this.fd = fdObj;
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   238
        this.append = false;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
         * FileDescriptor is being shared by streams.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
         * Ensure that it's GC'ed only when all the streams/channels are done
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
         * using it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        fd.incrementAndGetUseCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    /**
47
c8f0e41aea68 6631352: File{OutputStream,Writer} should implement atomic append mode using FILE_APPEND_DATA (win)
martin
parents: 46
diff changeset
   249
     * Opens a file, with the specified name, for overwriting or appending.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     * @param name name of file to be opened
47
c8f0e41aea68 6631352: File{OutputStream,Writer} should implement atomic append mode using FILE_APPEND_DATA (win)
martin
parents: 46
diff changeset
   251
     * @param append whether the file is to be opened in append mode
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     */
47
c8f0e41aea68 6631352: File{OutputStream,Writer} should implement atomic append mode using FILE_APPEND_DATA (win)
martin
parents: 46
diff changeset
   253
    private native void open(String name, boolean append)
c8f0e41aea68 6631352: File{OutputStream,Writer} should implement atomic append mode using FILE_APPEND_DATA (win)
martin
parents: 46
diff changeset
   254
        throws FileNotFoundException;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    /**
7515
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   257
     * Writes the specified byte to this file output stream.
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   258
     *
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   259
     * @param   b   the byte to be written.
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   260
     * @param   append   {@code true} if the write operation first
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   261
     *     advances the position to the end of file
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   262
     */
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   263
    private native void write(int b, boolean append) throws IOException;
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   264
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   265
    /**
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     * Writes the specified byte to this file output stream. Implements
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     * the <code>write</code> method of <code>OutputStream</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     * @param      b   the byte to be written.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     * @exception  IOException  if an I/O error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     */
7515
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   272
    public void write(int b) throws IOException {
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   273
        write(b, append);
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   274
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     * Writes a sub array as a sequence of bytes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     * @param b the data to be written
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     * @param off the start offset in the data
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     * @param len the number of bytes that are written
7515
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   281
     * @param append {@code true} to first advance the position to the
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   282
     *     end of file
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     * @exception IOException If an I/O error has occurred.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
     */
7515
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   285
    private native void writeBytes(byte b[], int off, int len, boolean append)
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   286
        throws IOException;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     * Writes <code>b.length</code> bytes from the specified byte array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
     * to this file output stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     * @param      b   the data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     * @exception  IOException  if an I/O error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
    public void write(byte b[]) throws IOException {
7515
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   296
        writeBytes(b, 0, b.length, append);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     * Writes <code>len</code> bytes from the specified byte array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
     * starting at offset <code>off</code> to this file output stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     * @param      b     the data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     * @param      off   the start offset in the data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     * @param      len   the number of bytes to write.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     * @exception  IOException  if an I/O error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
    public void write(byte b[], int off, int len) throws IOException {
7515
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   309
        writeBytes(b, off, len, append);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
     * Closes this file output stream and releases any system resources
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
     * associated with this stream. This file output stream may no longer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
     * be used for writing bytes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     * <p> If this stream has an associated channel then the channel is closed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     * as well.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     * @exception  IOException  if an I/O error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
     * @revised 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
     * @spec JSR-51
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
    public void close() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
        synchronized (closeLock) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
            if (closed) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
            closed = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
        if (channel != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
            /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
             * Decrement FD use count associated with the channel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
             * The use count is incremented whenever a new channel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
             * is obtained from this stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
            fd.decrementAndGetUseCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
            channel.close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
         * Decrement FD use count associated with this stream
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
        int useCount = fd.decrementAndGetUseCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
        /*
10586
6e20ecfec8ed 7082769: FileInputStream/FileOutputStream/RandomAccessFile allow file descriptor be closed when still in use
coffeys
parents: 9035
diff changeset
   349
         * If FileDescriptor is still in use by another stream, we
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
         * will not close it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
         */
10586
6e20ecfec8ed 7082769: FileInputStream/FileOutputStream/RandomAccessFile allow file descriptor be closed when still in use
coffeys
parents: 9035
diff changeset
   352
        if (useCount <= 0) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
            close0();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     * Returns the file descriptor associated with this stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
     * @return  the <code>FileDescriptor</code> object that represents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
     *          the connection to the file in the file system being used
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
     *          by this <code>FileOutputStream</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
     * @exception  IOException  if an I/O error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
     * @see        java.io.FileDescriptor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
     public final FileDescriptor getFD()  throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
        if (fd != null) return fd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
        throw new IOException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
     }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
     * Returns the unique {@link java.nio.channels.FileChannel FileChannel}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
     * object associated with this file output stream. </p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
     * <p> The initial {@link java.nio.channels.FileChannel#position()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
     * </code>position<code>} of the returned channel will be equal to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
     * number of bytes written to the file so far unless this stream is in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
     * append mode, in which case it will be equal to the size of the file.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
     * Writing bytes to this stream will increment the channel's position
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
     * accordingly.  Changing the channel's position, either explicitly or by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
     * writing, will change this stream's file position.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
     * @return  the file channel associated with this file output stream
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
     * @spec JSR-51
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
    public FileChannel getChannel() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
        synchronized (this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
            if (channel == null) {
7515
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   392
                channel = FileChannelImpl.open(fd, false, true, append, this);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
                /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
                 * Increment fd's use count. Invoking the channel's close()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
                 * method will result in decrementing the use count set for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
                 * the channel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
                 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
                fd.incrementAndGetUseCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
            return channel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
     * Cleans up the connection to the file, and ensures that the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
     * <code>close</code> method of this file output stream is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
     * called when there are no more references to this stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
     * @exception  IOException  if an I/O error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
     * @see        java.io.FileInputStream#close()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
    protected void finalize() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
        if (fd != null) {
46
ddf5deb2a633 6631437: File{In,Out}putStream minor improvements to spec and stylistic improvements to code
martin
parents: 2
diff changeset
   415
            if (fd == FileDescriptor.out || fd == FileDescriptor.err) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
                flush();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
                    close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
    private native void close0() throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
    private static native void initIDs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
        initIDs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
}