< prev index next >

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

Print this page




1852         if (sm != null) {
1853             sm.checkPermission(new RuntimePermission("getFileSystemAttributes"));
1854             sm.checkRead(path);
1855         }
1856         if (isInvalid()) {
1857             return 0L;
1858         }
1859         return fs.getSpace(this, FileSystem.SPACE_FREE);
1860     }
1861 
1862     /**
1863      * Returns the number of bytes available to this virtual machine on the
1864      * partition <a href="#partName">named</a> by this abstract pathname.  When
1865      * possible, this method checks for write permissions and other operating
1866      * system restrictions and will therefore usually provide a more accurate
1867      * estimate of how much new data can actually be written than {@link
1868      * #getFreeSpace}.
1869      *
1870      * <p> The returned number of available bytes is a hint, but not a
1871      * guarantee, that it is possible to use most or any of these bytes.  The
1872      * number of available bytes is most likely to be accurate immediately
1873      * after this call.  It is likely to be made inaccurate by any external
1874      * I/O operations including those made on the system outside of this
1875      * virtual machine.  This method makes no guarantee that write operations
1876      * to this file system will succeed.
1877      *
1878      * @return  The number of available bytes on the partition or {@code 0L}
1879      *          if the abstract pathname does not name a partition.  On
1880      *          systems where this information is not available, this method
1881      *          will be equivalent to a call to {@link #getFreeSpace}.
1882      *
1883      * @throws  SecurityException
1884      *          If a security manager has been installed and it denies
1885      *          {@link RuntimePermission}{@code ("getFileSystemAttributes")}
1886      *          or its {@link SecurityManager#checkRead(String)} method denies
1887      *          read access to the file named by this abstract pathname
1888      *
1889      * @since  1.6
1890      */
1891     public long getUsableSpace() {
1892         SecurityManager sm = System.getSecurityManager();




1852         if (sm != null) {
1853             sm.checkPermission(new RuntimePermission("getFileSystemAttributes"));
1854             sm.checkRead(path);
1855         }
1856         if (isInvalid()) {
1857             return 0L;
1858         }
1859         return fs.getSpace(this, FileSystem.SPACE_FREE);
1860     }
1861 
1862     /**
1863      * Returns the number of bytes available to this virtual machine on the
1864      * partition <a href="#partName">named</a> by this abstract pathname.  When
1865      * possible, this method checks for write permissions and other operating
1866      * system restrictions and will therefore usually provide a more accurate
1867      * estimate of how much new data can actually be written than {@link
1868      * #getFreeSpace}.
1869      *
1870      * <p> The returned number of available bytes is a hint, but not a
1871      * guarantee, that it is possible to use most or any of these bytes.  The
1872      * number of unallocated bytes is most likely to be accurate immediately
1873      * after this call.  It is likely to be made inaccurate by any external
1874      * I/O operations including those made on the system outside of this
1875      * virtual machine.  This method makes no guarantee that write operations
1876      * to this file system will succeed.
1877      *
1878      * @return  The number of available bytes on the partition or {@code 0L}
1879      *          if the abstract pathname does not name a partition.  On
1880      *          systems where this information is not available, this method
1881      *          will be equivalent to a call to {@link #getFreeSpace}.
1882      *
1883      * @throws  SecurityException
1884      *          If a security manager has been installed and it denies
1885      *          {@link RuntimePermission}{@code ("getFileSystemAttributes")}
1886      *          or its {@link SecurityManager#checkRead(String)} method denies
1887      *          read access to the file named by this abstract pathname
1888      *
1889      * @since  1.6
1890      */
1891     public long getUsableSpace() {
1892         SecurityManager sm = System.getSecurityManager();


< prev index next >