< prev index next >

src/java.base/share/classes/java/io/FileDescriptor.java

Print this page

190      *
191      * sync is meant to be used by code that requires physical
192      * storage (such as a file) to be in a known state  For
193      * example, a class that provided a simple transaction facility
194      * might use sync to ensure that all changes to a file caused
195      * by a given transaction were recorded on a storage medium.
196      *
197      * sync only affects buffers downstream of this FileDescriptor.  If
198      * any in-memory buffering is being done by the application (for
199      * example, by a BufferedOutputStream object), those buffers must
200      * be flushed into the FileDescriptor (for example, by invoking
201      * OutputStream.flush) before that data will be affected by sync.
202      *
203      * @throws    SyncFailedException
204      *        Thrown when the buffers cannot be flushed,
205      *        or because the system cannot guarantee that all the
206      *        buffers have been synchronized with physical media.
207      * @since     1.1
208      */
209     public void sync() throws SyncFailedException {
210         long comp = Blocker.begin();
211         try {
212             sync0();
213         } finally {
214             Blocker.end(comp);
215         }
216     }
217 
218     /* fsync/equivalent this file descriptor */
219     private native void sync0() throws SyncFailedException;
220 
221     /* This routine initializes JNI field offsets for the class */
222     private static native void initIDs();
223 
224     /*
225      * On Windows return the handle for the standard streams.
226      */
227     private static native long getHandle(int d);
228 
229     /**
230      * Returns true, if the file was opened for appending.
231      */
232     private static native boolean getAppend(int fd);
233 
234     /**

190      *
191      * sync is meant to be used by code that requires physical
192      * storage (such as a file) to be in a known state  For
193      * example, a class that provided a simple transaction facility
194      * might use sync to ensure that all changes to a file caused
195      * by a given transaction were recorded on a storage medium.
196      *
197      * sync only affects buffers downstream of this FileDescriptor.  If
198      * any in-memory buffering is being done by the application (for
199      * example, by a BufferedOutputStream object), those buffers must
200      * be flushed into the FileDescriptor (for example, by invoking
201      * OutputStream.flush) before that data will be affected by sync.
202      *
203      * @throws    SyncFailedException
204      *        Thrown when the buffers cannot be flushed,
205      *        or because the system cannot guarantee that all the
206      *        buffers have been synchronized with physical media.
207      * @since     1.1
208      */
209     public void sync() throws SyncFailedException {
210         boolean attempted = Blocker.beginCompenstate();
211         try {
212             sync0();
213         } finally {
214             Blocker.endCompenstate(attempted);
215         }
216     }
217 
218     /* fsync/equivalent this file descriptor */
219     private native void sync0() throws SyncFailedException;
220 
221     /* This routine initializes JNI field offsets for the class */
222     private static native void initIDs();
223 
224     /*
225      * On Windows return the handle for the standard streams.
226      */
227     private static native long getHandle(int d);
228 
229     /**
230      * Returns true, if the file was opened for appending.
231      */
232     private static native boolean getAppend(int fd);
233 
234     /**
< prev index next >