119 * @see java.lang.SecurityManager#checkRead(java.lang.String)
120 * @see java.lang.SecurityManager#checkWrite(java.lang.String)
121 * @revised 1.4
122 * @spec JSR-51
123 */
124 public RandomAccessFile(String name, String mode)
125 throws FileNotFoundException
126 {
127 this(name != null ? new File(name) : null, mode);
128 }
129
130 /**
131 * Creates a random access file stream to read from, and optionally to
132 * write to, the file specified by the {@link File} argument. A new {@link
133 * FileDescriptor} object is created to represent this file connection.
134 *
135 * <p>The <a id="mode">{@code mode}</a> argument specifies the access mode
136 * in which the file is to be opened. The permitted values and their
137 * meanings are:
138 *
139 * <table summary="Access mode permitted values and meanings">
140 * <tr><th style="text-align:left">Value</th><th style="text-align:left">Meaning</th></tr>
141 * <tr><td style="vertical-align:top">{@code "r"}</td>
142 * <td> Open for reading only. Invoking any of the {@code write}
143 * methods of the resulting object will cause an
144 * {@link java.io.IOException} to be thrown.</td></tr>
145 * <tr><td style="vertical-align:top">{@code "rw"}</td>
146 * <td> Open for reading and writing. If the file does not already
147 * exist then an attempt will be made to create it.</td></tr>
148 * <tr><td style="vertical-align:top">{@code "rws"}</td>
149 * <td> Open for reading and writing, as with {@code "rw"}, and also
150 * require that every update to the file's content or metadata be
151 * written synchronously to the underlying storage device.</td></tr>
152 * <tr><td style="vertical-align:top">{@code "rwd"}</td>
153 * <td> Open for reading and writing, as with {@code "rw"}, and also
154 * require that every update to the file's content be written
155 * synchronously to the underlying storage device.</td></tr>
156 * </table>
157 *
158 * The {@code "rws"} and {@code "rwd"} modes work much like the {@link
159 * java.nio.channels.FileChannel#force(boolean) force(boolean)} method of
160 * the {@link java.nio.channels.FileChannel} class, passing arguments of
161 * {@code true} and {@code false}, respectively, except that they always
162 * apply to every I/O operation and are therefore often more efficient. If
163 * the file resides on a local storage device then when an invocation of a
164 * method of this class returns it is guaranteed that all changes made to
165 * the file by that invocation will have been written to that device. This
166 * is useful for ensuring that critical information is not lost in the
167 * event of a system crash. If the file does not reside on a local device
168 * then no such guarantee is made.
169 *
170 * <p>The {@code "rwd"} mode can be used to reduce the number of I/O
171 * operations performed. Using {@code "rwd"} only requires updates to the
172 * file's content to be written to storage; using {@code "rws"} requires
173 * updates to both the file's content and its metadata to be written, which
174 * generally requires at least one more low-level I/O operation.
175 *
|
119 * @see java.lang.SecurityManager#checkRead(java.lang.String)
120 * @see java.lang.SecurityManager#checkWrite(java.lang.String)
121 * @revised 1.4
122 * @spec JSR-51
123 */
124 public RandomAccessFile(String name, String mode)
125 throws FileNotFoundException
126 {
127 this(name != null ? new File(name) : null, mode);
128 }
129
130 /**
131 * Creates a random access file stream to read from, and optionally to
132 * write to, the file specified by the {@link File} argument. A new {@link
133 * FileDescriptor} object is created to represent this file connection.
134 *
135 * <p>The <a id="mode">{@code mode}</a> argument specifies the access mode
136 * in which the file is to be opened. The permitted values and their
137 * meanings are:
138 *
139 * <table class="altrows">
140 * <caption style="display:none">Access mode permitted values and meanings</caption>
141 * <thead>
142 * <tr><th style="text-align:left">Value</th><th style="text-align:left">Meaning</th></tr>
143 * </thead>
144 * <tbody>
145 * <tr><td style="vertical-align:top">{@code "r"}</td>
146 * <td> Open for reading only. Invoking any of the {@code write}
147 * methods of the resulting object will cause an
148 * {@link java.io.IOException} to be thrown.</td></tr>
149 * <tr><td style="vertical-align:top">{@code "rw"}</td>
150 * <td> Open for reading and writing. If the file does not already
151 * exist then an attempt will be made to create it.</td></tr>
152 * <tr><td style="vertical-align:top">{@code "rws"}</td>
153 * <td> Open for reading and writing, as with {@code "rw"}, and also
154 * require that every update to the file's content or metadata be
155 * written synchronously to the underlying storage device.</td></tr>
156 * <tr><td style="vertical-align:top">{@code "rwd"}</td>
157 * <td> Open for reading and writing, as with {@code "rw"}, and also
158 * require that every update to the file's content be written
159 * synchronously to the underlying storage device.</td></tr>
160 * </tbody>
161 * </table>
162 *
163 * The {@code "rws"} and {@code "rwd"} modes work much like the {@link
164 * java.nio.channels.FileChannel#force(boolean) force(boolean)} method of
165 * the {@link java.nio.channels.FileChannel} class, passing arguments of
166 * {@code true} and {@code false}, respectively, except that they always
167 * apply to every I/O operation and are therefore often more efficient. If
168 * the file resides on a local storage device then when an invocation of a
169 * method of this class returns it is guaranteed that all changes made to
170 * the file by that invocation will have been written to that device. This
171 * is useful for ensuring that critical information is not lost in the
172 * event of a system crash. If the file does not reside on a local device
173 * then no such guarantee is made.
174 *
175 * <p>The {@code "rwd"} mode can be used to reduce the number of I/O
176 * operations performed. Using {@code "rwd"} only requires updates to the
177 * file's content to be written to storage; using {@code "rws"} requires
178 * updates to both the file's content and its metadata to be written, which
179 * generally requires at least one more low-level I/O operation.
180 *
|