507 lines
28 KiB
HTML
507 lines
28 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
<!-- NewPage -->
|
|
<html lang="en">
|
|
<head>
|
|
<!-- Generated by javadoc -->
|
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
|
<title>FileSystemUtils (Apache Commons IO 2.11.0 API)</title>
|
|
<link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">
|
|
<script type="text/javascript" src="../../../../script.js"></script>
|
|
</head>
|
|
<body>
|
|
<script type="text/javascript"><!--
|
|
try {
|
|
if (location.href.indexOf('is-external=true') == -1) {
|
|
parent.document.title="FileSystemUtils (Apache Commons IO 2.11.0 API)";
|
|
}
|
|
}
|
|
catch(err) {
|
|
}
|
|
//-->
|
|
var methods = {"i0":41,"i1":41,"i2":41,"i3":41,"i4":41};
|
|
var tabs = {65535:["t0","All Methods"],1:["t1","Static Methods"],8:["t4","Concrete Methods"],32:["t6","Deprecated Methods"]};
|
|
var altColor = "altColor";
|
|
var rowColor = "rowColor";
|
|
var tableTab = "tableTab";
|
|
var activeTableTab = "activeTableTab";
|
|
</script>
|
|
<noscript>
|
|
<div>JavaScript is disabled on your browser.</div>
|
|
</noscript>
|
|
<!-- ========= START OF TOP NAVBAR ======= -->
|
|
<div class="topNav"><a name="navbar.top">
|
|
<!-- -->
|
|
</a>
|
|
<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
|
|
<a name="navbar.top.firstrow">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="navList" title="Navigation">
|
|
<li><a href="../../../../overview-summary.html">Overview</a></li>
|
|
<li><a href="package-summary.html">Package</a></li>
|
|
<li class="navBarCell1Rev">Class</li>
|
|
<li><a href="class-use/FileSystemUtils.html">Use</a></li>
|
|
<li><a href="package-tree.html">Tree</a></li>
|
|
<li><a href="../../../../deprecated-list.html">Deprecated</a></li>
|
|
<li><a href="../../../../index-all.html">Index</a></li>
|
|
<li><a href="../../../../help-doc.html">Help</a></li>
|
|
</ul>
|
|
</div>
|
|
<div class="subNav">
|
|
<ul class="navList">
|
|
<li><a href="../../../../org/apache/commons/io/FileSystem.html" title="enum in org.apache.commons.io"><span class="typeNameLink">Prev Class</span></a></li>
|
|
<li><a href="../../../../org/apache/commons/io/FileUtils.html" title="class in org.apache.commons.io"><span class="typeNameLink">Next Class</span></a></li>
|
|
</ul>
|
|
<ul class="navList">
|
|
<li><a href="../../../../index.html?org/apache/commons/io/FileSystemUtils.html" target="_top">Frames</a></li>
|
|
<li><a href="FileSystemUtils.html" target="_top">No Frames</a></li>
|
|
</ul>
|
|
<ul class="navList" id="allclasses_navbar_top">
|
|
<li><a href="../../../../allclasses-noframe.html">All Classes</a></li>
|
|
</ul>
|
|
<div>
|
|
<script type="text/javascript"><!--
|
|
allClassesLink = document.getElementById("allclasses_navbar_top");
|
|
if(window==top) {
|
|
allClassesLink.style.display = "block";
|
|
}
|
|
else {
|
|
allClassesLink.style.display = "none";
|
|
}
|
|
//-->
|
|
</script>
|
|
</div>
|
|
<div>
|
|
<ul class="subNavList">
|
|
<li>Summary: </li>
|
|
<li>Nested | </li>
|
|
<li>Field | </li>
|
|
<li><a href="#constructor.summary">Constr</a> | </li>
|
|
<li><a href="#method.summary">Method</a></li>
|
|
</ul>
|
|
<ul class="subNavList">
|
|
<li>Detail: </li>
|
|
<li>Field | </li>
|
|
<li><a href="#constructor.detail">Constr</a> | </li>
|
|
<li><a href="#method.detail">Method</a></li>
|
|
</ul>
|
|
</div>
|
|
<a name="skip.navbar.top">
|
|
<!-- -->
|
|
</a></div>
|
|
<!-- ========= END OF TOP NAVBAR ========= -->
|
|
<!-- ======== START OF CLASS DATA ======== -->
|
|
<div class="header">
|
|
<div class="subTitle">org.apache.commons.io</div>
|
|
<h2 title="Class FileSystemUtils" class="title">Class FileSystemUtils</h2>
|
|
</div>
|
|
<div class="contentContainer">
|
|
<ul class="inheritance">
|
|
<li><a href="https://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">java.lang.Object</a></li>
|
|
<li>
|
|
<ul class="inheritance">
|
|
<li>org.apache.commons.io.FileSystemUtils</li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
<div class="description">
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<hr>
|
|
<div class="block"><span class="deprecatedLabel">Deprecated.</span>
|
|
<div class="block"><span class="deprecationComment">As of 2.6 deprecated without replacement. Use equivalent
|
|
methods in <a href="https://docs.oracle.com/javase/7/docs/api/java/nio/file/FileStore.html?is-external=true" title="class or interface in java.nio.file"><code>FileStore</code></a> instead, e.g.
|
|
<code>Files.getFileStore(Paths.get("/home")).getUsableSpace()</code>
|
|
or iterate over <code>FileSystems.getDefault().getFileStores()</code></span></div>
|
|
</div>
|
|
<br>
|
|
<pre><a href="https://docs.oracle.com/javase/7/docs/api/java/lang/Deprecated.html?is-external=true" title="class or interface in java.lang">@Deprecated</a>
|
|
public class <span class="typeNameLabel">FileSystemUtils</span>
|
|
extends <a href="https://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></pre>
|
|
<div class="block">General File System utilities.
|
|
<p>
|
|
This class provides static utility methods for general file system
|
|
functions not provided via the JDK <a href="https://docs.oracle.com/javase/7/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io"><code>File</code></a> class.
|
|
<p>
|
|
The current functions provided are:
|
|
<ul>
|
|
<li>Get the free space on a drive
|
|
</ul></div>
|
|
<dl>
|
|
<dt><span class="simpleTagLabel">Since:</span></dt>
|
|
<dd>1.1</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<div class="summary">
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
|
|
<ul class="blockList">
|
|
<li class="blockList"><a name="constructor.summary">
|
|
<!-- -->
|
|
</a>
|
|
<h3>Constructor Summary</h3>
|
|
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Constructor Summary table, listing constructors, and an explanation">
|
|
<caption><span>Constructors</span><span class="tabEnd"> </span></caption>
|
|
<tr>
|
|
<th class="colOne" scope="col">Constructor and Description</th>
|
|
</tr>
|
|
<tr class="altColor">
|
|
<td class="colOne"><code><span class="memberNameLink"><a href="../../../../org/apache/commons/io/FileSystemUtils.html#FileSystemUtils--">FileSystemUtils</a></span>()</code>
|
|
<div class="block"><span class="deprecatedLabel">Deprecated.</span> </div>
|
|
<div class="block">Instances should NOT be constructed in standard programming.</div>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</li>
|
|
</ul>
|
|
<!-- ========== METHOD SUMMARY =========== -->
|
|
<ul class="blockList">
|
|
<li class="blockList"><a name="method.summary">
|
|
<!-- -->
|
|
</a>
|
|
<h3>Method Summary</h3>
|
|
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
|
|
<caption><span id="t0" class="activeTableTab"><span>All Methods</span><span class="tabEnd"> </span></span><span id="t1" class="tableTab"><span><a href="javascript:show(1);">Static Methods</a></span><span class="tabEnd"> </span></span><span id="t4" class="tableTab"><span><a href="javascript:show(8);">Concrete Methods</a></span><span class="tabEnd"> </span></span><span id="t6" class="tableTab"><span><a href="javascript:show(32);">Deprecated Methods</a></span><span class="tabEnd"> </span></span></caption>
|
|
<tr>
|
|
<th class="colFirst" scope="col">Modifier and Type</th>
|
|
<th class="colLast" scope="col">Method and Description</th>
|
|
</tr>
|
|
<tr id="i0" class="altColor">
|
|
<td class="colFirst"><code>static long</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/commons/io/FileSystemUtils.html#freeSpace-java.lang.String-">freeSpace</a></span>(<a href="https://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> path)</code>
|
|
<div class="block"><span class="deprecatedLabel">Deprecated.</span>
|
|
<div class="block"><span class="deprecationComment">Use freeSpaceKb(String)
|
|
Deprecated from 1.3, may be removed in 2.0</span></div>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i1" class="rowColor">
|
|
<td class="colFirst"><code>static long</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/commons/io/FileSystemUtils.html#freeSpaceKb--">freeSpaceKb</a></span>()</code>
|
|
<div class="block"><span class="deprecatedLabel">Deprecated.</span>
|
|
<div class="block"><span class="deprecationComment">As of 2.6 deprecated without replacement. Please use <a href="https://docs.oracle.com/javase/7/docs/api/java/nio/file/FileStore.html?is-external=true#getUsableSpace--" title="class or interface in java.nio.file"><code>FileStore.getUsableSpace()</code></a>.</span></div>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i2" class="altColor">
|
|
<td class="colFirst"><code>static long</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/commons/io/FileSystemUtils.html#freeSpaceKb-long-">freeSpaceKb</a></span>(long timeout)</code>
|
|
<div class="block"><span class="deprecatedLabel">Deprecated.</span>
|
|
<div class="block"><span class="deprecationComment">As of 2.6 deprecated without replacement. Please use <a href="https://docs.oracle.com/javase/7/docs/api/java/nio/file/FileStore.html?is-external=true#getUsableSpace--" title="class or interface in java.nio.file"><code>FileStore.getUsableSpace()</code></a>.</span></div>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i3" class="rowColor">
|
|
<td class="colFirst"><code>static long</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/commons/io/FileSystemUtils.html#freeSpaceKb-java.lang.String-">freeSpaceKb</a></span>(<a href="https://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> path)</code>
|
|
<div class="block"><span class="deprecatedLabel">Deprecated.</span>
|
|
<div class="block"><span class="deprecationComment">As of 2.6 deprecated without replacement. Please use <a href="https://docs.oracle.com/javase/7/docs/api/java/nio/file/FileStore.html?is-external=true#getUsableSpace--" title="class or interface in java.nio.file"><code>FileStore.getUsableSpace()</code></a>.</span></div>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i4" class="altColor">
|
|
<td class="colFirst"><code>static long</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/commons/io/FileSystemUtils.html#freeSpaceKb-java.lang.String-long-">freeSpaceKb</a></span>(<a href="https://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> path,
|
|
long timeout)</code>
|
|
<div class="block"><span class="deprecatedLabel">Deprecated.</span>
|
|
<div class="block"><span class="deprecationComment">As of 2.6 deprecated without replacement. Please use <a href="https://docs.oracle.com/javase/7/docs/api/java/nio/file/FileStore.html?is-external=true#getUsableSpace--" title="class or interface in java.nio.file"><code>FileStore.getUsableSpace()</code></a>.</span></div>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<ul class="blockList">
|
|
<li class="blockList"><a name="methods.inherited.from.class.java.lang.Object">
|
|
<!-- -->
|
|
</a>
|
|
<h3>Methods inherited from class java.lang.<a href="https://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></h3>
|
|
<code><a href="https://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#clone--" title="class or interface in java.lang">clone</a>, <a href="https://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#equals-java.lang.Object-" title="class or interface in java.lang">equals</a>, <a href="https://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#finalize--" title="class or interface in java.lang">finalize</a>, <a href="https://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#getClass--" title="class or interface in java.lang">getClass</a>, <a href="https://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#hashCode--" title="class or interface in java.lang">hashCode</a>, <a href="https://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#notify--" title="class or interface in java.lang">notify</a>, <a href="https://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#notifyAll--" title="class or interface in java.lang">notifyAll</a>, <a href="https://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#toString--" title="class or interface in java.lang">toString</a>, <a href="https://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#wait--" title="class or interface in java.lang">wait</a>, <a href="https://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#wait-long-" title="class or interface in java.lang">wait</a>, <a href="https://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#wait-long-int-" title="class or interface in java.lang">wait</a></code></li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<div class="details">
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<!-- ========= CONSTRUCTOR DETAIL ======== -->
|
|
<ul class="blockList">
|
|
<li class="blockList"><a name="constructor.detail">
|
|
<!-- -->
|
|
</a>
|
|
<h3>Constructor Detail</h3>
|
|
<a name="FileSystemUtils--">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockListLast">
|
|
<li class="blockList">
|
|
<h4>FileSystemUtils</h4>
|
|
<pre>public FileSystemUtils()</pre>
|
|
<div class="block"><span class="deprecatedLabel">Deprecated.</span> </div>
|
|
<div class="block">Instances should NOT be constructed in standard programming.</div>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
<!-- ============ METHOD DETAIL ========== -->
|
|
<ul class="blockList">
|
|
<li class="blockList"><a name="method.detail">
|
|
<!-- -->
|
|
</a>
|
|
<h3>Method Detail</h3>
|
|
<a name="freeSpace-java.lang.String-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>freeSpace</h4>
|
|
<pre><a href="https://docs.oracle.com/javase/7/docs/api/java/lang/Deprecated.html?is-external=true" title="class or interface in java.lang">@Deprecated</a>
|
|
public static long freeSpace(<a href="https://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> path)
|
|
throws <a href="https://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></pre>
|
|
<div class="block"><span class="deprecatedLabel">Deprecated.</span> <span class="deprecationComment">Use freeSpaceKb(String)
|
|
Deprecated from 1.3, may be removed in 2.0</span></div>
|
|
<div class="block">Returns the free space on a drive or volume by invoking
|
|
the command line.
|
|
This method does not normalize the result, and typically returns
|
|
bytes on Windows, 512 byte units on OS X and kilobytes on Unix.
|
|
As this is not very useful, this method is deprecated in favour
|
|
of <a href="../../../../org/apache/commons/io/FileSystemUtils.html#freeSpaceKb-java.lang.String-"><code>freeSpaceKb(String)</code></a> which returns a result in kilobytes.
|
|
<p>
|
|
Note that some OS's are NOT currently supported, including OS/390,
|
|
OpenVMS.
|
|
<pre>
|
|
FileSystemUtils.freeSpace("C:"); // Windows
|
|
FileSystemUtils.freeSpace("/volume"); // *nix
|
|
</pre>
|
|
The free space is calculated via the command line.
|
|
It uses 'dir /-c' on Windows and 'df' on *nix.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>path</code> - the path to get free space for, not null, not empty on Unix</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>the amount of free drive space on the drive or volume</dd>
|
|
<dt><span class="throwsLabel">Throws:</span></dt>
|
|
<dd><code><a href="https://docs.oracle.com/javase/7/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</a></code> - if the path is invalid</dd>
|
|
<dd><code><a href="https://docs.oracle.com/javase/7/docs/api/java/lang/IllegalStateException.html?is-external=true" title="class or interface in java.lang">IllegalStateException</a></code> - if an error occurred in initialisation</dd>
|
|
<dd><code><a href="https://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></code> - if an error occurs when finding the free space</dd>
|
|
<dt><span class="simpleTagLabel">Since:</span></dt>
|
|
<dd>1.1, enhanced OS support in 1.2 and 1.3</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="freeSpaceKb-java.lang.String-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>freeSpaceKb</h4>
|
|
<pre><a href="https://docs.oracle.com/javase/7/docs/api/java/lang/Deprecated.html?is-external=true" title="class or interface in java.lang">@Deprecated</a>
|
|
public static long freeSpaceKb(<a href="https://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> path)
|
|
throws <a href="https://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></pre>
|
|
<div class="block"><span class="deprecatedLabel">Deprecated.</span> <span class="deprecationComment">As of 2.6 deprecated without replacement. Please use <a href="https://docs.oracle.com/javase/7/docs/api/java/nio/file/FileStore.html?is-external=true#getUsableSpace--" title="class or interface in java.nio.file"><code>FileStore.getUsableSpace()</code></a>.</span></div>
|
|
<div class="block">Returns the free space on a drive or volume in kibibytes (1024 bytes)
|
|
by invoking the command line.
|
|
<pre>
|
|
FileSystemUtils.freeSpaceKb("C:"); // Windows
|
|
FileSystemUtils.freeSpaceKb("/volume"); // *nix
|
|
</pre>
|
|
The free space is calculated via the command line.
|
|
It uses 'dir /-c' on Windows, 'df -kP' on AIX/HP-UX and 'df -k' on other Unix.
|
|
<p>
|
|
In order to work, you must be running Windows, or have a implementation of
|
|
Unix df that supports GNU format when passed -k (or -kP). If you are going
|
|
to rely on this code, please check that it works on your OS by running
|
|
some simple tests to compare the command line with the output from this class.
|
|
If your operating system isn't supported, please raise a JIRA call detailing
|
|
the exact result from df -k and as much other detail as possible, thanks.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>path</code> - the path to get free space for, not null, not empty on Unix</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>the amount of free drive space on the drive or volume in kilobytes</dd>
|
|
<dt><span class="throwsLabel">Throws:</span></dt>
|
|
<dd><code><a href="https://docs.oracle.com/javase/7/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</a></code> - if the path is invalid</dd>
|
|
<dd><code><a href="https://docs.oracle.com/javase/7/docs/api/java/lang/IllegalStateException.html?is-external=true" title="class or interface in java.lang">IllegalStateException</a></code> - if an error occurred in initialisation</dd>
|
|
<dd><code><a href="https://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></code> - if an error occurs when finding the free space</dd>
|
|
<dt><span class="simpleTagLabel">Since:</span></dt>
|
|
<dd>1.2, enhanced OS support in 1.3</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="freeSpaceKb-java.lang.String-long-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>freeSpaceKb</h4>
|
|
<pre><a href="https://docs.oracle.com/javase/7/docs/api/java/lang/Deprecated.html?is-external=true" title="class or interface in java.lang">@Deprecated</a>
|
|
public static long freeSpaceKb(<a href="https://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> path,
|
|
long timeout)
|
|
throws <a href="https://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></pre>
|
|
<div class="block"><span class="deprecatedLabel">Deprecated.</span> <span class="deprecationComment">As of 2.6 deprecated without replacement. Please use <a href="https://docs.oracle.com/javase/7/docs/api/java/nio/file/FileStore.html?is-external=true#getUsableSpace--" title="class or interface in java.nio.file"><code>FileStore.getUsableSpace()</code></a>.</span></div>
|
|
<div class="block">Returns the free space on a drive or volume in kibibytes (1024 bytes)
|
|
by invoking the command line.
|
|
<pre>
|
|
FileSystemUtils.freeSpaceKb("C:"); // Windows
|
|
FileSystemUtils.freeSpaceKb("/volume"); // *nix
|
|
</pre>
|
|
The free space is calculated via the command line.
|
|
It uses 'dir /-c' on Windows, 'df -kP' on AIX/HP-UX and 'df -k' on other Unix.
|
|
<p>
|
|
In order to work, you must be running Windows, or have a implementation of
|
|
Unix df that supports GNU format when passed -k (or -kP). If you are going
|
|
to rely on this code, please check that it works on your OS by running
|
|
some simple tests to compare the command line with the output from this class.
|
|
If your operating system isn't supported, please raise a JIRA call detailing
|
|
the exact result from df -k and as much other detail as possible, thanks.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>path</code> - the path to get free space for, not null, not empty on Unix</dd>
|
|
<dd><code>timeout</code> - The timeout amount in milliseconds or no timeout if the value
|
|
is zero or less</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>the amount of free drive space on the drive or volume in kilobytes</dd>
|
|
<dt><span class="throwsLabel">Throws:</span></dt>
|
|
<dd><code><a href="https://docs.oracle.com/javase/7/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</a></code> - if the path is invalid</dd>
|
|
<dd><code><a href="https://docs.oracle.com/javase/7/docs/api/java/lang/IllegalStateException.html?is-external=true" title="class or interface in java.lang">IllegalStateException</a></code> - if an error occurred in initialisation</dd>
|
|
<dd><code><a href="https://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></code> - if an error occurs when finding the free space</dd>
|
|
<dt><span class="simpleTagLabel">Since:</span></dt>
|
|
<dd>2.0</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="freeSpaceKb--">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>freeSpaceKb</h4>
|
|
<pre><a href="https://docs.oracle.com/javase/7/docs/api/java/lang/Deprecated.html?is-external=true" title="class or interface in java.lang">@Deprecated</a>
|
|
public static long freeSpaceKb()
|
|
throws <a href="https://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></pre>
|
|
<div class="block"><span class="deprecatedLabel">Deprecated.</span> <span class="deprecationComment">As of 2.6 deprecated without replacement. Please use <a href="https://docs.oracle.com/javase/7/docs/api/java/nio/file/FileStore.html?is-external=true#getUsableSpace--" title="class or interface in java.nio.file"><code>FileStore.getUsableSpace()</code></a>.</span></div>
|
|
<div class="block">Returns the free space for the working directory
|
|
in kibibytes (1024 bytes) by invoking the command line.
|
|
<p>
|
|
Identical to:
|
|
<pre>
|
|
freeSpaceKb(new File(".").getAbsolutePath())
|
|
</pre></div>
|
|
<dl>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>the amount of free drive space on the drive or volume in kilobytes</dd>
|
|
<dt><span class="throwsLabel">Throws:</span></dt>
|
|
<dd><code><a href="https://docs.oracle.com/javase/7/docs/api/java/lang/IllegalStateException.html?is-external=true" title="class or interface in java.lang">IllegalStateException</a></code> - if an error occurred in initialisation</dd>
|
|
<dd><code><a href="https://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></code> - if an error occurs when finding the free space</dd>
|
|
<dt><span class="simpleTagLabel">Since:</span></dt>
|
|
<dd>2.0</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="freeSpaceKb-long-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockListLast">
|
|
<li class="blockList">
|
|
<h4>freeSpaceKb</h4>
|
|
<pre><a href="https://docs.oracle.com/javase/7/docs/api/java/lang/Deprecated.html?is-external=true" title="class or interface in java.lang">@Deprecated</a>
|
|
public static long freeSpaceKb(long timeout)
|
|
throws <a href="https://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></pre>
|
|
<div class="block"><span class="deprecatedLabel">Deprecated.</span> <span class="deprecationComment">As of 2.6 deprecated without replacement. Please use <a href="https://docs.oracle.com/javase/7/docs/api/java/nio/file/FileStore.html?is-external=true#getUsableSpace--" title="class or interface in java.nio.file"><code>FileStore.getUsableSpace()</code></a>.</span></div>
|
|
<div class="block">Returns the free space for the working directory
|
|
in kibibytes (1024 bytes) by invoking the command line.
|
|
<p>
|
|
Identical to:
|
|
<pre>
|
|
freeSpaceKb(new File(".").getAbsolutePath())
|
|
</pre></div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>timeout</code> - The timeout amount in milliseconds or no timeout if the value
|
|
is zero or less</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>the amount of free drive space on the drive or volume in kilobytes</dd>
|
|
<dt><span class="throwsLabel">Throws:</span></dt>
|
|
<dd><code><a href="https://docs.oracle.com/javase/7/docs/api/java/lang/IllegalStateException.html?is-external=true" title="class or interface in java.lang">IllegalStateException</a></code> - if an error occurred in initialisation</dd>
|
|
<dd><code><a href="https://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></code> - if an error occurs when finding the free space</dd>
|
|
<dt><span class="simpleTagLabel">Since:</span></dt>
|
|
<dd>2.0</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<!-- ========= END OF CLASS DATA ========= -->
|
|
<!-- ======= START OF BOTTOM NAVBAR ====== -->
|
|
<div class="bottomNav"><a name="navbar.bottom">
|
|
<!-- -->
|
|
</a>
|
|
<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
|
|
<a name="navbar.bottom.firstrow">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="navList" title="Navigation">
|
|
<li><a href="../../../../overview-summary.html">Overview</a></li>
|
|
<li><a href="package-summary.html">Package</a></li>
|
|
<li class="navBarCell1Rev">Class</li>
|
|
<li><a href="class-use/FileSystemUtils.html">Use</a></li>
|
|
<li><a href="package-tree.html">Tree</a></li>
|
|
<li><a href="../../../../deprecated-list.html">Deprecated</a></li>
|
|
<li><a href="../../../../index-all.html">Index</a></li>
|
|
<li><a href="../../../../help-doc.html">Help</a></li>
|
|
</ul>
|
|
</div>
|
|
<div class="subNav">
|
|
<ul class="navList">
|
|
<li><a href="../../../../org/apache/commons/io/FileSystem.html" title="enum in org.apache.commons.io"><span class="typeNameLink">Prev Class</span></a></li>
|
|
<li><a href="../../../../org/apache/commons/io/FileUtils.html" title="class in org.apache.commons.io"><span class="typeNameLink">Next Class</span></a></li>
|
|
</ul>
|
|
<ul class="navList">
|
|
<li><a href="../../../../index.html?org/apache/commons/io/FileSystemUtils.html" target="_top">Frames</a></li>
|
|
<li><a href="FileSystemUtils.html" target="_top">No Frames</a></li>
|
|
</ul>
|
|
<ul class="navList" id="allclasses_navbar_bottom">
|
|
<li><a href="../../../../allclasses-noframe.html">All Classes</a></li>
|
|
</ul>
|
|
<div>
|
|
<script type="text/javascript"><!--
|
|
allClassesLink = document.getElementById("allclasses_navbar_bottom");
|
|
if(window==top) {
|
|
allClassesLink.style.display = "block";
|
|
}
|
|
else {
|
|
allClassesLink.style.display = "none";
|
|
}
|
|
//-->
|
|
</script>
|
|
</div>
|
|
<div>
|
|
<ul class="subNavList">
|
|
<li>Summary: </li>
|
|
<li>Nested | </li>
|
|
<li>Field | </li>
|
|
<li><a href="#constructor.summary">Constr</a> | </li>
|
|
<li><a href="#method.summary">Method</a></li>
|
|
</ul>
|
|
<ul class="subNavList">
|
|
<li>Detail: </li>
|
|
<li>Field | </li>
|
|
<li><a href="#constructor.detail">Constr</a> | </li>
|
|
<li><a href="#method.detail">Method</a></li>
|
|
</ul>
|
|
</div>
|
|
<a name="skip.navbar.bottom">
|
|
<!-- -->
|
|
</a></div>
|
|
<!-- ======== END OF BOTTOM NAVBAR ======= -->
|
|
<p class="legalCopy"><small>Copyright © 2002–2021 <a href="https://www.apache.org/">The Apache Software Foundation</a>. All rights reserved.</small></p>
|
|
</body>
|
|
</html>
|