1638 lines
90 KiB
HTML
1638 lines
90 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>FilenameUtils (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="FilenameUtils (Apache Commons IO 2.11.0 API)";
|
|
}
|
|
}
|
|
catch(err) {
|
|
}
|
|
//-->
|
|
var methods = {"i0":9,"i1":9,"i2":9,"i3":9,"i4":9,"i5":9,"i6":9,"i7":9,"i8":9,"i9":9,"i10":9,"i11":9,"i12":9,"i13":9,"i14":9,"i15":9,"i16":9,"i17":9,"i18":9,"i19":9,"i20":9,"i21":9,"i22":9,"i23":9,"i24":9,"i25":9,"i26":9,"i27":9,"i28":9,"i29":9,"i30":9,"i31":9};
|
|
var tabs = {65535:["t0","All Methods"],1:["t1","Static Methods"],8:["t4","Concrete 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/FilenameUtils.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/FileExistsException.html" title="class in org.apache.commons.io"><span class="typeNameLink">Prev Class</span></a></li>
|
|
<li><a href="../../../../org/apache/commons/io/FileSystem.html" title="enum 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/FilenameUtils.html" target="_top">Frames</a></li>
|
|
<li><a href="FilenameUtils.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><a href="#field.summary">Field</a> | </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><a href="#field.detail">Field</a> | </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 FilenameUtils" class="title">Class FilenameUtils</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.FilenameUtils</li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
<div class="description">
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<hr>
|
|
<br>
|
|
<pre>public class <span class="typeNameLabel">FilenameUtils</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 name and file path manipulation utilities.
|
|
<p>
|
|
When dealing with file names you can hit problems when moving from a Windows
|
|
based development machine to a Unix based production machine.
|
|
This class aims to help avoid those problems.
|
|
<p>
|
|
<b>NOTE</b>: You may be able to avoid using this class entirely simply by
|
|
using 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> objects and the two argument constructor
|
|
<a href="https://docs.oracle.com/javase/7/docs/api/java/io/File.html?is-external=true#File-java.io.File-java.lang.String-" title="class or interface in java.io"><code>File(File,String)</code></a>.
|
|
<p>
|
|
Most methods on this class are designed to work the same on both Unix and Windows.
|
|
Those that don't include 'System', 'Unix' or 'Windows' in their name.
|
|
<p>
|
|
Most methods recognize both separators (forward and back), and both
|
|
sets of prefixes. See the Javadoc of each method for details.
|
|
<p>
|
|
This class defines six components within a file name
|
|
(example C:\dev\project\file.txt):
|
|
<ul>
|
|
<li>the prefix - C:\</li>
|
|
<li>the path - dev\project\</li>
|
|
<li>the full path - C:\dev\project\</li>
|
|
<li>the name - file.txt</li>
|
|
<li>the base name - file</li>
|
|
<li>the extension - txt</li>
|
|
</ul>
|
|
Note that this class works best if directory file names end with a separator.
|
|
If you omit the last separator, it is impossible to determine if the file name
|
|
corresponds to a file or a directory. As a result, we have chosen to say
|
|
it corresponds to a file.
|
|
<p>
|
|
This class only supports Unix and Windows style names.
|
|
Prefixes are matched as follows:
|
|
<pre>
|
|
Windows:
|
|
a\b\c.txt --> "" --> relative
|
|
\a\b\c.txt --> "\" --> current drive absolute
|
|
C:a\b\c.txt --> "C:" --> drive relative
|
|
C:\a\b\c.txt --> "C:\" --> absolute
|
|
\\server\a\b\c.txt --> "\\server\" --> UNC
|
|
|
|
Unix:
|
|
a/b/c.txt --> "" --> relative
|
|
/a/b/c.txt --> "/" --> absolute
|
|
~/a/b/c.txt --> "~/" --> current user
|
|
~ --> "~/" --> current user (slash added)
|
|
~user/a/b/c.txt --> "~user/" --> named user
|
|
~user --> "~user/" --> named user (slash added)
|
|
</pre>
|
|
Both prefix styles are matched always, irrespective of the machine that you are
|
|
currently running on.
|
|
<p>
|
|
Origin of code: Excalibur, Alexandria, Tomcat, Commons-Utils.</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">
|
|
<!-- =========== FIELD SUMMARY =========== -->
|
|
<ul class="blockList">
|
|
<li class="blockList"><a name="field.summary">
|
|
<!-- -->
|
|
</a>
|
|
<h3>Field Summary</h3>
|
|
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Field Summary table, listing fields, and an explanation">
|
|
<caption><span>Fields</span><span class="tabEnd"> </span></caption>
|
|
<tr>
|
|
<th class="colFirst" scope="col">Modifier and Type</th>
|
|
<th class="colLast" scope="col">Field and Description</th>
|
|
</tr>
|
|
<tr class="altColor">
|
|
<td class="colFirst"><code>static char</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/commons/io/FilenameUtils.html#EXTENSION_SEPARATOR">EXTENSION_SEPARATOR</a></span></code>
|
|
<div class="block">The extension separator character.</div>
|
|
</td>
|
|
</tr>
|
|
<tr class="rowColor">
|
|
<td class="colFirst"><code>static <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></code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/commons/io/FilenameUtils.html#EXTENSION_SEPARATOR_STR">EXTENSION_SEPARATOR_STR</a></span></code>
|
|
<div class="block">The extension separator String.</div>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</li>
|
|
</ul>
|
|
<!-- ======== 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/FilenameUtils.html#FilenameUtils--">FilenameUtils</a></span>()</code>
|
|
<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></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 <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></code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/commons/io/FilenameUtils.html#concat-java.lang.String-java.lang.String-">concat</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> basePath,
|
|
<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> fullFileNameToAdd)</code>
|
|
<div class="block">Concatenates a fileName to a base path using normal command line style rules.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i1" class="rowColor">
|
|
<td class="colFirst"><code>static boolean</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/commons/io/FilenameUtils.html#directoryContains-java.lang.String-java.lang.String-">directoryContains</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> canonicalParent,
|
|
<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> canonicalChild)</code>
|
|
<div class="block">Determines whether the <code>parent</code> directory contains the <code>child</code> element (a file or directory).</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i2" class="altColor">
|
|
<td class="colFirst"><code>static boolean</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/commons/io/FilenameUtils.html#equals-java.lang.String-java.lang.String-">equals</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> fileName1,
|
|
<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> fileName2)</code>
|
|
<div class="block">Checks whether two fileNames are equal exactly.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i3" class="rowColor">
|
|
<td class="colFirst"><code>static boolean</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/commons/io/FilenameUtils.html#equals-java.lang.String-java.lang.String-boolean-org.apache.commons.io.IOCase-">equals</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> fileName1,
|
|
<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> fileName2,
|
|
boolean normalized,
|
|
<a href="../../../../org/apache/commons/io/IOCase.html" title="enum in org.apache.commons.io">IOCase</a> caseSensitivity)</code>
|
|
<div class="block">Checks whether two fileNames are equal, optionally normalizing and providing
|
|
control over the case-sensitivity.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i4" class="altColor">
|
|
<td class="colFirst"><code>static boolean</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/commons/io/FilenameUtils.html#equalsNormalized-java.lang.String-java.lang.String-">equalsNormalized</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> fileName1,
|
|
<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> fileName2)</code>
|
|
<div class="block">Checks whether two fileNames are equal after both have been normalized.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i5" class="rowColor">
|
|
<td class="colFirst"><code>static boolean</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/commons/io/FilenameUtils.html#equalsNormalizedOnSystem-java.lang.String-java.lang.String-">equalsNormalizedOnSystem</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> fileName1,
|
|
<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> fileName2)</code>
|
|
<div class="block">Checks whether two fileNames are equal after both have been normalized
|
|
and using the case rules of the system.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i6" class="altColor">
|
|
<td class="colFirst"><code>static boolean</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/commons/io/FilenameUtils.html#equalsOnSystem-java.lang.String-java.lang.String-">equalsOnSystem</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> fileName1,
|
|
<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> fileName2)</code>
|
|
<div class="block">Checks whether two fileNames are equal using the case rules of the system.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i7" class="rowColor">
|
|
<td class="colFirst"><code>static <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></code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/commons/io/FilenameUtils.html#getBaseName-java.lang.String-">getBaseName</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> fileName)</code>
|
|
<div class="block">Gets the base name, minus the full path and extension, from a full fileName.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i8" class="altColor">
|
|
<td class="colFirst"><code>static <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></code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/commons/io/FilenameUtils.html#getExtension-java.lang.String-">getExtension</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> fileName)</code>
|
|
<div class="block">Gets the extension of a fileName.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i9" class="rowColor">
|
|
<td class="colFirst"><code>static <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></code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/commons/io/FilenameUtils.html#getFullPath-java.lang.String-">getFullPath</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> fileName)</code>
|
|
<div class="block">Gets the full path from a full fileName, which is the prefix + path.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i10" class="altColor">
|
|
<td class="colFirst"><code>static <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></code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/commons/io/FilenameUtils.html#getFullPathNoEndSeparator-java.lang.String-">getFullPathNoEndSeparator</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> fileName)</code>
|
|
<div class="block">Gets the full path from a full fileName, which is the prefix + path,
|
|
and also excluding the final directory separator.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i11" class="rowColor">
|
|
<td class="colFirst"><code>static <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></code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/commons/io/FilenameUtils.html#getName-java.lang.String-">getName</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> fileName)</code>
|
|
<div class="block">Gets the name minus the path from a full fileName.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i12" class="altColor">
|
|
<td class="colFirst"><code>static <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></code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/commons/io/FilenameUtils.html#getPath-java.lang.String-">getPath</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> fileName)</code>
|
|
<div class="block">Gets the path from a full fileName, which excludes the prefix.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i13" class="rowColor">
|
|
<td class="colFirst"><code>static <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></code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/commons/io/FilenameUtils.html#getPathNoEndSeparator-java.lang.String-">getPathNoEndSeparator</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> fileName)</code>
|
|
<div class="block">Gets the path from a full fileName, which excludes the prefix, and
|
|
also excluding the final directory separator.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i14" class="altColor">
|
|
<td class="colFirst"><code>static <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></code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/commons/io/FilenameUtils.html#getPrefix-java.lang.String-">getPrefix</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> fileName)</code>
|
|
<div class="block">Gets the prefix from a full fileName, such as <code>C:/</code>
|
|
or <code>~/</code>.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i15" class="rowColor">
|
|
<td class="colFirst"><code>static int</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/commons/io/FilenameUtils.html#getPrefixLength-java.lang.String-">getPrefixLength</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> fileName)</code>
|
|
<div class="block">Returns the length of the fileName prefix, such as <code>C:/</code> or <code>~/</code>.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i16" class="altColor">
|
|
<td class="colFirst"><code>static int</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/commons/io/FilenameUtils.html#indexOfExtension-java.lang.String-">indexOfExtension</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> fileName)</code>
|
|
<div class="block">Returns the index of the last extension separator character, which is a dot.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i17" class="rowColor">
|
|
<td class="colFirst"><code>static int</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/commons/io/FilenameUtils.html#indexOfLastSeparator-java.lang.String-">indexOfLastSeparator</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> fileName)</code>
|
|
<div class="block">Returns the index of the last directory separator character.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i18" class="altColor">
|
|
<td class="colFirst"><code>static boolean</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/commons/io/FilenameUtils.html#isExtension-java.lang.String-java.util.Collection-">isExtension</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> fileName,
|
|
<a href="https://docs.oracle.com/javase/7/docs/api/java/util/Collection.html?is-external=true" title="class or interface in java.util">Collection</a><<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>> extensions)</code>
|
|
<div class="block">Checks whether the extension of the fileName is one of those specified.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i19" class="rowColor">
|
|
<td class="colFirst"><code>static boolean</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/commons/io/FilenameUtils.html#isExtension-java.lang.String-java.lang.String...-">isExtension</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> fileName,
|
|
<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>... extensions)</code>
|
|
<div class="block">Checks whether the extension of the fileName is one of those specified.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i20" class="altColor">
|
|
<td class="colFirst"><code>static boolean</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/commons/io/FilenameUtils.html#isExtension-java.lang.String-java.lang.String-">isExtension</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> fileName,
|
|
<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> extension)</code>
|
|
<div class="block">Checks whether the extension of the fileName is that specified.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i21" class="rowColor">
|
|
<td class="colFirst"><code>static <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></code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/commons/io/FilenameUtils.html#normalize-java.lang.String-">normalize</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> fileName)</code>
|
|
<div class="block">Normalizes a path, removing double and single dot path steps.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i22" class="altColor">
|
|
<td class="colFirst"><code>static <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></code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/commons/io/FilenameUtils.html#normalize-java.lang.String-boolean-">normalize</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> fileName,
|
|
boolean unixSeparator)</code>
|
|
<div class="block">Normalizes a path, removing double and single dot path steps.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i23" class="rowColor">
|
|
<td class="colFirst"><code>static <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></code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/commons/io/FilenameUtils.html#normalizeNoEndSeparator-java.lang.String-">normalizeNoEndSeparator</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> fileName)</code>
|
|
<div class="block">Normalizes a path, removing double and single dot path steps,
|
|
and removing any final directory separator.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i24" class="altColor">
|
|
<td class="colFirst"><code>static <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></code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/commons/io/FilenameUtils.html#normalizeNoEndSeparator-java.lang.String-boolean-">normalizeNoEndSeparator</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> fileName,
|
|
boolean unixSeparator)</code>
|
|
<div class="block">Normalizes a path, removing double and single dot path steps,
|
|
and removing any final directory separator.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i25" class="rowColor">
|
|
<td class="colFirst"><code>static <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></code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/commons/io/FilenameUtils.html#removeExtension-java.lang.String-">removeExtension</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> fileName)</code>
|
|
<div class="block">Removes the extension from a fileName.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i26" class="altColor">
|
|
<td class="colFirst"><code>static <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></code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/commons/io/FilenameUtils.html#separatorsToSystem-java.lang.String-">separatorsToSystem</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">Converts all separators to the system separator.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i27" class="rowColor">
|
|
<td class="colFirst"><code>static <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></code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/commons/io/FilenameUtils.html#separatorsToUnix-java.lang.String-">separatorsToUnix</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">Converts all separators to the Unix separator of forward slash.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i28" class="altColor">
|
|
<td class="colFirst"><code>static <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></code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/commons/io/FilenameUtils.html#separatorsToWindows-java.lang.String-">separatorsToWindows</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">Converts all separators to the Windows separator of backslash.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i29" class="rowColor">
|
|
<td class="colFirst"><code>static boolean</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/commons/io/FilenameUtils.html#wildcardMatch-java.lang.String-java.lang.String-">wildcardMatch</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> fileName,
|
|
<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> wildcardMatcher)</code>
|
|
<div class="block">Checks a fileName to see if it matches the specified wildcard matcher,
|
|
always testing case-sensitive.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i30" class="altColor">
|
|
<td class="colFirst"><code>static boolean</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/commons/io/FilenameUtils.html#wildcardMatch-java.lang.String-java.lang.String-org.apache.commons.io.IOCase-">wildcardMatch</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> fileName,
|
|
<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> wildcardMatcher,
|
|
<a href="../../../../org/apache/commons/io/IOCase.html" title="enum in org.apache.commons.io">IOCase</a> caseSensitivity)</code>
|
|
<div class="block">Checks a fileName to see if it matches the specified wildcard matcher
|
|
allowing control over case-sensitivity.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i31" class="rowColor">
|
|
<td class="colFirst"><code>static boolean</code></td>
|
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/commons/io/FilenameUtils.html#wildcardMatchOnSystem-java.lang.String-java.lang.String-">wildcardMatchOnSystem</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> fileName,
|
|
<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> wildcardMatcher)</code>
|
|
<div class="block">Checks a fileName to see if it matches the specified wildcard matcher
|
|
using the case rules of the system.</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">
|
|
<!-- ============ FIELD DETAIL =========== -->
|
|
<ul class="blockList">
|
|
<li class="blockList"><a name="field.detail">
|
|
<!-- -->
|
|
</a>
|
|
<h3>Field Detail</h3>
|
|
<a name="EXTENSION_SEPARATOR">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>EXTENSION_SEPARATOR</h4>
|
|
<pre>public static final char EXTENSION_SEPARATOR</pre>
|
|
<div class="block">The extension separator character.</div>
|
|
<dl>
|
|
<dt><span class="simpleTagLabel">Since:</span></dt>
|
|
<dd>1.4</dd>
|
|
<dt><span class="seeLabel">See Also:</span></dt>
|
|
<dd><a href="../../../../constant-values.html#org.apache.commons.io.FilenameUtils.EXTENSION_SEPARATOR">Constant Field Values</a></dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="EXTENSION_SEPARATOR_STR">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockListLast">
|
|
<li class="blockList">
|
|
<h4>EXTENSION_SEPARATOR_STR</h4>
|
|
<pre>public static final <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> EXTENSION_SEPARATOR_STR</pre>
|
|
<div class="block">The extension separator String.</div>
|
|
<dl>
|
|
<dt><span class="simpleTagLabel">Since:</span></dt>
|
|
<dd>1.4</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
<!-- ========= CONSTRUCTOR DETAIL ======== -->
|
|
<ul class="blockList">
|
|
<li class="blockList"><a name="constructor.detail">
|
|
<!-- -->
|
|
</a>
|
|
<h3>Constructor Detail</h3>
|
|
<a name="FilenameUtils--">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockListLast">
|
|
<li class="blockList">
|
|
<h4>FilenameUtils</h4>
|
|
<pre>public FilenameUtils()</pre>
|
|
<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="normalize-java.lang.String-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>normalize</h4>
|
|
<pre>public static <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> normalize(<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> fileName)</pre>
|
|
<div class="block">Normalizes a path, removing double and single dot path steps.
|
|
<p>
|
|
This method normalizes a path to a standard format.
|
|
The input may contain separators in either Unix or Windows format.
|
|
The output will contain separators in the format of the system.
|
|
<p>
|
|
A trailing slash will be retained.
|
|
A double slash will be merged to a single slash (but UNC names are handled).
|
|
A single dot path segment will be removed.
|
|
A double dot will cause that path segment and the one before to be removed.
|
|
If the double dot has no parent path segment to work with, <code>null</code>
|
|
is returned.
|
|
<p>
|
|
The output will be the same on both Unix and Windows except
|
|
for the separator character.
|
|
<pre>
|
|
/foo// --> /foo/
|
|
/foo/./ --> /foo/
|
|
/foo/../bar --> /bar
|
|
/foo/../bar/ --> /bar/
|
|
/foo/../bar/../baz --> /baz
|
|
//foo//./bar --> /foo/bar
|
|
/../ --> null
|
|
../foo --> null
|
|
foo/bar/.. --> foo/
|
|
foo/../../bar --> null
|
|
foo/../bar --> bar
|
|
//server/foo/../bar --> //server/bar
|
|
//server/../bar --> null
|
|
C:\foo\..\bar --> C:\bar
|
|
C:\..\bar --> null
|
|
~/foo/../bar/ --> ~/bar/
|
|
~/../bar --> null
|
|
</pre>
|
|
(Note the file separator returned will be correct for Windows/Unix)</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>fileName</code> - the fileName to normalize, null returns null</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>the normalized fileName, or null if invalid. Null bytes inside string will be removed</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="normalize-java.lang.String-boolean-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>normalize</h4>
|
|
<pre>public static <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> normalize(<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> fileName,
|
|
boolean unixSeparator)</pre>
|
|
<div class="block">Normalizes a path, removing double and single dot path steps.
|
|
<p>
|
|
This method normalizes a path to a standard format.
|
|
The input may contain separators in either Unix or Windows format.
|
|
The output will contain separators in the format specified.
|
|
<p>
|
|
A trailing slash will be retained.
|
|
A double slash will be merged to a single slash (but UNC names are handled).
|
|
A single dot path segment will be removed.
|
|
A double dot will cause that path segment and the one before to be removed.
|
|
If the double dot has no parent path segment to work with, <code>null</code>
|
|
is returned.
|
|
<p>
|
|
The output will be the same on both Unix and Windows except
|
|
for the separator character.
|
|
<pre>
|
|
/foo// --> /foo/
|
|
/foo/./ --> /foo/
|
|
/foo/../bar --> /bar
|
|
/foo/../bar/ --> /bar/
|
|
/foo/../bar/../baz --> /baz
|
|
//foo//./bar --> /foo/bar
|
|
/../ --> null
|
|
../foo --> null
|
|
foo/bar/.. --> foo/
|
|
foo/../../bar --> null
|
|
foo/../bar --> bar
|
|
//server/foo/../bar --> //server/bar
|
|
//server/../bar --> null
|
|
C:\foo\..\bar --> C:\bar
|
|
C:\..\bar --> null
|
|
~/foo/../bar/ --> ~/bar/
|
|
~/../bar --> null
|
|
</pre>
|
|
The output will be the same on both Unix and Windows including
|
|
the separator character.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>fileName</code> - the fileName to normalize, null returns null</dd>
|
|
<dd><code>unixSeparator</code> - <code>true</code> if a unix separator should
|
|
be used or <code>false</code> if a windows separator should be used.</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>the normalized fileName, or null if invalid. Null bytes inside string will be removed</dd>
|
|
<dt><span class="simpleTagLabel">Since:</span></dt>
|
|
<dd>2.0</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="normalizeNoEndSeparator-java.lang.String-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>normalizeNoEndSeparator</h4>
|
|
<pre>public static <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> normalizeNoEndSeparator(<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> fileName)</pre>
|
|
<div class="block">Normalizes a path, removing double and single dot path steps,
|
|
and removing any final directory separator.
|
|
<p>
|
|
This method normalizes a path to a standard format.
|
|
The input may contain separators in either Unix or Windows format.
|
|
The output will contain separators in the format of the system.
|
|
<p>
|
|
A trailing slash will be removed.
|
|
A double slash will be merged to a single slash (but UNC names are handled).
|
|
A single dot path segment will be removed.
|
|
A double dot will cause that path segment and the one before to be removed.
|
|
If the double dot has no parent path segment to work with, <code>null</code>
|
|
is returned.
|
|
<p>
|
|
The output will be the same on both Unix and Windows except
|
|
for the separator character.
|
|
<pre>
|
|
/foo// --> /foo
|
|
/foo/./ --> /foo
|
|
/foo/../bar --> /bar
|
|
/foo/../bar/ --> /bar
|
|
/foo/../bar/../baz --> /baz
|
|
//foo//./bar --> /foo/bar
|
|
/../ --> null
|
|
../foo --> null
|
|
foo/bar/.. --> foo
|
|
foo/../../bar --> null
|
|
foo/../bar --> bar
|
|
//server/foo/../bar --> //server/bar
|
|
//server/../bar --> null
|
|
C:\foo\..\bar --> C:\bar
|
|
C:\..\bar --> null
|
|
~/foo/../bar/ --> ~/bar
|
|
~/../bar --> null
|
|
</pre>
|
|
(Note the file separator returned will be correct for Windows/Unix)</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>fileName</code> - the fileName to normalize, null returns null</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>the normalized fileName, or null if invalid. Null bytes inside string will be removed</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="normalizeNoEndSeparator-java.lang.String-boolean-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>normalizeNoEndSeparator</h4>
|
|
<pre>public static <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> normalizeNoEndSeparator(<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> fileName,
|
|
boolean unixSeparator)</pre>
|
|
<div class="block">Normalizes a path, removing double and single dot path steps,
|
|
and removing any final directory separator.
|
|
<p>
|
|
This method normalizes a path to a standard format.
|
|
The input may contain separators in either Unix or Windows format.
|
|
The output will contain separators in the format specified.
|
|
<p>
|
|
A trailing slash will be removed.
|
|
A double slash will be merged to a single slash (but UNC names are handled).
|
|
A single dot path segment will be removed.
|
|
A double dot will cause that path segment and the one before to be removed.
|
|
If the double dot has no parent path segment to work with, <code>null</code>
|
|
is returned.
|
|
<p>
|
|
The output will be the same on both Unix and Windows including
|
|
the separator character.
|
|
<pre>
|
|
/foo// --> /foo
|
|
/foo/./ --> /foo
|
|
/foo/../bar --> /bar
|
|
/foo/../bar/ --> /bar
|
|
/foo/../bar/../baz --> /baz
|
|
//foo//./bar --> /foo/bar
|
|
/../ --> null
|
|
../foo --> null
|
|
foo/bar/.. --> foo
|
|
foo/../../bar --> null
|
|
foo/../bar --> bar
|
|
//server/foo/../bar --> //server/bar
|
|
//server/../bar --> null
|
|
C:\foo\..\bar --> C:\bar
|
|
C:\..\bar --> null
|
|
~/foo/../bar/ --> ~/bar
|
|
~/../bar --> null
|
|
</pre></div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>fileName</code> - the fileName to normalize, null returns null</dd>
|
|
<dd><code>unixSeparator</code> - <code>true</code> if a unix separator should
|
|
be used or <code>false</code> if a windows separator should be used.</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>the normalized fileName, or null if invalid. Null bytes inside string will be removed</dd>
|
|
<dt><span class="simpleTagLabel">Since:</span></dt>
|
|
<dd>2.0</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="concat-java.lang.String-java.lang.String-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>concat</h4>
|
|
<pre>public static <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> concat(<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> basePath,
|
|
<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> fullFileNameToAdd)</pre>
|
|
<div class="block">Concatenates a fileName to a base path using normal command line style rules.
|
|
<p>
|
|
The effect is equivalent to resultant directory after changing
|
|
directory to the first argument, followed by changing directory to
|
|
the second argument.
|
|
<p>
|
|
The first argument is the base path, the second is the path to concatenate.
|
|
The returned path is always normalized via <a href="../../../../org/apache/commons/io/FilenameUtils.html#normalize-java.lang.String-"><code>normalize(String)</code></a>,
|
|
thus <code>..</code> is handled.
|
|
<p>
|
|
If <code>pathToAdd</code> is absolute (has an absolute prefix), then
|
|
it will be normalized and returned.
|
|
Otherwise, the paths will be joined, normalized and returned.
|
|
<p>
|
|
The output will be the same on both Unix and Windows except
|
|
for the separator character.
|
|
<pre>
|
|
/foo/ + bar --> /foo/bar
|
|
/foo + bar --> /foo/bar
|
|
/foo + /bar --> /bar
|
|
/foo + C:/bar --> C:/bar
|
|
/foo + C:bar --> C:bar (*)
|
|
/foo/a/ + ../bar --> /foo/bar
|
|
/foo/ + ../../bar --> null
|
|
/foo/ + /bar --> /bar
|
|
/foo/.. + /bar --> /bar
|
|
/foo + bar/c.txt --> /foo/bar/c.txt
|
|
/foo/c.txt + bar --> /foo/c.txt/bar (!)
|
|
</pre>
|
|
(*) Note that the Windows relative drive prefix is unreliable when
|
|
used with this method.
|
|
(!) Note that the first parameter must be a path. If it ends with a name, then
|
|
the name will be built into the concatenated path. If this might be a problem,
|
|
use <a href="../../../../org/apache/commons/io/FilenameUtils.html#getFullPath-java.lang.String-"><code>getFullPath(String)</code></a> on the base path argument.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>basePath</code> - the base path to attach to, always treated as a path</dd>
|
|
<dd><code>fullFileNameToAdd</code> - the fileName (or path) to attach to the base</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>the concatenated path, or null if invalid. Null bytes inside string will be removed</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="directoryContains-java.lang.String-java.lang.String-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>directoryContains</h4>
|
|
<pre>public static boolean directoryContains(<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> canonicalParent,
|
|
<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> canonicalChild)</pre>
|
|
<div class="block">Determines whether the <code>parent</code> directory contains the <code>child</code> element (a file or directory).
|
|
<p>
|
|
The files names are expected to be normalized.
|
|
</p>
|
|
|
|
Edge cases:
|
|
<ul>
|
|
<li>A <code>directory</code> must not be null: if null, throw IllegalArgumentException</li>
|
|
<li>A directory does not contain itself: return false</li>
|
|
<li>A null child file is not contained in any parent: return false</li>
|
|
</ul></div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>canonicalParent</code> - the file to consider as the parent.</dd>
|
|
<dd><code>canonicalChild</code> - the file to consider as the child.</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>true is the candidate leaf is under by the specified composite. False otherwise.</dd>
|
|
<dt><span class="simpleTagLabel">Since:</span></dt>
|
|
<dd>2.2</dd>
|
|
<dt><span class="seeLabel">See Also:</span></dt>
|
|
<dd><a href="../../../../org/apache/commons/io/FileUtils.html#directoryContains-java.io.File-java.io.File-"><code>FileUtils.directoryContains(File, File)</code></a></dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="separatorsToUnix-java.lang.String-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>separatorsToUnix</h4>
|
|
<pre>public static <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> separatorsToUnix(<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)</pre>
|
|
<div class="block">Converts all separators to the Unix separator of forward slash.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>path</code> - the path to be changed, null ignored</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>the updated path</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="separatorsToWindows-java.lang.String-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>separatorsToWindows</h4>
|
|
<pre>public static <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> separatorsToWindows(<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)</pre>
|
|
<div class="block">Converts all separators to the Windows separator of backslash.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>path</code> - the path to be changed, null ignored</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>the updated path</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="separatorsToSystem-java.lang.String-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>separatorsToSystem</h4>
|
|
<pre>public static <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> separatorsToSystem(<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)</pre>
|
|
<div class="block">Converts all separators to the system separator.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>path</code> - the path to be changed, null ignored</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>the updated path</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="getPrefixLength-java.lang.String-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>getPrefixLength</h4>
|
|
<pre>public static int getPrefixLength(<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> fileName)</pre>
|
|
<div class="block">Returns the length of the fileName prefix, such as <code>C:/</code> or <code>~/</code>.
|
|
<p>
|
|
This method will handle a file in either Unix or Windows format.
|
|
<p>
|
|
The prefix length includes the first slash in the full fileName
|
|
if applicable. Thus, it is possible that the length returned is greater
|
|
than the length of the input string.
|
|
<pre>
|
|
Windows:
|
|
a\b\c.txt --> 0 --> relative
|
|
\a\b\c.txt --> 1 --> current drive absolute
|
|
C:a\b\c.txt --> 2 --> drive relative
|
|
C:\a\b\c.txt --> 3 --> absolute
|
|
\\server\a\b\c.txt --> 9 --> UNC
|
|
\\\a\b\c.txt --> -1 --> error
|
|
|
|
Unix:
|
|
a/b/c.txt --> 0 --> relative
|
|
/a/b/c.txt --> 1 --> absolute
|
|
~/a/b/c.txt --> 2 --> current user
|
|
~ --> 2 --> current user (slash added)
|
|
~user/a/b/c.txt --> 6 --> named user
|
|
~user --> 6 --> named user (slash added)
|
|
//server/a/b/c.txt --> 9
|
|
///a/b/c.txt --> -1 --> error
|
|
C: --> 0 --> valid filename as only null byte and / are reserved characters
|
|
</pre>
|
|
<p>
|
|
The output will be the same irrespective of the machine that the code is running on.
|
|
ie. both Unix and Windows prefixes are matched regardless.
|
|
|
|
Note that a leading // (or \\) is used to indicate a UNC name on Windows.
|
|
These must be followed by a server name, so double-slashes are not collapsed
|
|
to a single slash at the start of the fileName.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>fileName</code> - the fileName to find the prefix in, null returns -1</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>the length of the prefix, -1 if invalid or null</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="indexOfLastSeparator-java.lang.String-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>indexOfLastSeparator</h4>
|
|
<pre>public static int indexOfLastSeparator(<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> fileName)</pre>
|
|
<div class="block">Returns the index of the last directory separator character.
|
|
<p>
|
|
This method will handle a file in either Unix or Windows format.
|
|
The position of the last forward or backslash is returned.
|
|
<p>
|
|
The output will be the same irrespective of the machine that the code is running on.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>fileName</code> - the fileName to find the last path separator in, null returns -1</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>the index of the last separator character, or -1 if there
|
|
is no such character</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="indexOfExtension-java.lang.String-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>indexOfExtension</h4>
|
|
<pre>public static int indexOfExtension(<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> fileName)
|
|
throws <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></pre>
|
|
<div class="block">Returns the index of the last extension separator character, which is a dot.
|
|
<p>
|
|
This method also checks that there is no directory separator after the last dot. To do this it uses
|
|
<a href="../../../../org/apache/commons/io/FilenameUtils.html#indexOfLastSeparator-java.lang.String-"><code>indexOfLastSeparator(String)</code></a> which will handle a file in either Unix or Windows format.
|
|
</p>
|
|
<p>
|
|
The output will be the same irrespective of the machine that the code is running on, with the
|
|
exception of a possible <a href="https://docs.oracle.com/javase/7/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang"><code>IllegalArgumentException</code></a> on Windows (see below).
|
|
</p>
|
|
<b>Note:</b> This method used to have a hidden problem for names like "foo.exe:bar.txt".
|
|
In this case, the name wouldn't be the name of a file, but the identifier of an
|
|
alternate data stream (bar.txt) on the file foo.exe. The method used to return
|
|
".txt" here, which would be misleading. Commons IO 2.7, and later versions, are throwing
|
|
an <a href="https://docs.oracle.com/javase/7/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang"><code>IllegalArgumentException</code></a> for names like this.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>fileName</code> - the fileName to find the last extension separator in, null returns -1</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>the index of the last extension separator character, or -1 if there is no such character</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> - <b>Windows only:</b> The fileName parameter is, in fact,
|
|
the identifier of an Alternate Data Stream, for example "foo.exe:bar.txt".</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="getPrefix-java.lang.String-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>getPrefix</h4>
|
|
<pre>public static <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> getPrefix(<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> fileName)</pre>
|
|
<div class="block">Gets the prefix from a full fileName, such as <code>C:/</code>
|
|
or <code>~/</code>.
|
|
<p>
|
|
This method will handle a file in either Unix or Windows format.
|
|
The prefix includes the first slash in the full fileName where applicable.
|
|
<pre>
|
|
Windows:
|
|
a\b\c.txt --> "" --> relative
|
|
\a\b\c.txt --> "\" --> current drive absolute
|
|
C:a\b\c.txt --> "C:" --> drive relative
|
|
C:\a\b\c.txt --> "C:\" --> absolute
|
|
\\server\a\b\c.txt --> "\\server\" --> UNC
|
|
|
|
Unix:
|
|
a/b/c.txt --> "" --> relative
|
|
/a/b/c.txt --> "/" --> absolute
|
|
~/a/b/c.txt --> "~/" --> current user
|
|
~ --> "~/" --> current user (slash added)
|
|
~user/a/b/c.txt --> "~user/" --> named user
|
|
~user --> "~user/" --> named user (slash added)
|
|
</pre>
|
|
<p>
|
|
The output will be the same irrespective of the machine that the code is running on.
|
|
ie. both Unix and Windows prefixes are matched regardless.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>fileName</code> - the fileName to query, null returns null</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>the prefix of the file, null if invalid. Null bytes inside string will be removed</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="getPath-java.lang.String-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>getPath</h4>
|
|
<pre>public static <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> getPath(<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> fileName)</pre>
|
|
<div class="block">Gets the path from a full fileName, which excludes the prefix.
|
|
<p>
|
|
This method will handle a file in either Unix or Windows format.
|
|
The method is entirely text based, and returns the text before and
|
|
including the last forward or backslash.
|
|
<pre>
|
|
C:\a\b\c.txt --> a\b\
|
|
~/a/b/c.txt --> a/b/
|
|
a.txt --> ""
|
|
a/b/c --> a/b/
|
|
a/b/c/ --> a/b/c/
|
|
</pre>
|
|
<p>
|
|
The output will be the same irrespective of the machine that the code is running on.
|
|
<p>
|
|
This method drops the prefix from the result.
|
|
See <a href="../../../../org/apache/commons/io/FilenameUtils.html#getFullPath-java.lang.String-"><code>getFullPath(String)</code></a> for the method that retains the prefix.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>fileName</code> - the fileName to query, null returns null</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>the path of the file, an empty string if none exists, null if invalid.
|
|
Null bytes inside string will be removed</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="getPathNoEndSeparator-java.lang.String-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>getPathNoEndSeparator</h4>
|
|
<pre>public static <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> getPathNoEndSeparator(<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> fileName)</pre>
|
|
<div class="block">Gets the path from a full fileName, which excludes the prefix, and
|
|
also excluding the final directory separator.
|
|
<p>
|
|
This method will handle a file in either Unix or Windows format.
|
|
The method is entirely text based, and returns the text before the
|
|
last forward or backslash.
|
|
<pre>
|
|
C:\a\b\c.txt --> a\b
|
|
~/a/b/c.txt --> a/b
|
|
a.txt --> ""
|
|
a/b/c --> a/b
|
|
a/b/c/ --> a/b/c
|
|
</pre>
|
|
<p>
|
|
The output will be the same irrespective of the machine that the code is running on.
|
|
<p>
|
|
This method drops the prefix from the result.
|
|
See <a href="../../../../org/apache/commons/io/FilenameUtils.html#getFullPathNoEndSeparator-java.lang.String-"><code>getFullPathNoEndSeparator(String)</code></a> for the method that retains the prefix.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>fileName</code> - the fileName to query, null returns null</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>the path of the file, an empty string if none exists, null if invalid.
|
|
Null bytes inside string will be removed</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="getFullPath-java.lang.String-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>getFullPath</h4>
|
|
<pre>public static <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> getFullPath(<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> fileName)</pre>
|
|
<div class="block">Gets the full path from a full fileName, which is the prefix + path.
|
|
<p>
|
|
This method will handle a file in either Unix or Windows format.
|
|
The method is entirely text based, and returns the text before and
|
|
including the last forward or backslash.
|
|
<pre>
|
|
C:\a\b\c.txt --> C:\a\b\
|
|
~/a/b/c.txt --> ~/a/b/
|
|
a.txt --> ""
|
|
a/b/c --> a/b/
|
|
a/b/c/ --> a/b/c/
|
|
C: --> C:
|
|
C:\ --> C:\
|
|
~ --> ~/
|
|
~/ --> ~/
|
|
~user --> ~user/
|
|
~user/ --> ~user/
|
|
</pre>
|
|
<p>
|
|
The output will be the same irrespective of the machine that the code is running on.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>fileName</code> - the fileName to query, null returns null</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>the path of the file, an empty string if none exists, null if invalid</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="getFullPathNoEndSeparator-java.lang.String-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>getFullPathNoEndSeparator</h4>
|
|
<pre>public static <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> getFullPathNoEndSeparator(<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> fileName)</pre>
|
|
<div class="block">Gets the full path from a full fileName, which is the prefix + path,
|
|
and also excluding the final directory separator.
|
|
<p>
|
|
This method will handle a file in either Unix or Windows format.
|
|
The method is entirely text based, and returns the text before the
|
|
last forward or backslash.
|
|
<pre>
|
|
C:\a\b\c.txt --> C:\a\b
|
|
~/a/b/c.txt --> ~/a/b
|
|
a.txt --> ""
|
|
a/b/c --> a/b
|
|
a/b/c/ --> a/b/c
|
|
C: --> C:
|
|
C:\ --> C:\
|
|
~ --> ~
|
|
~/ --> ~
|
|
~user --> ~user
|
|
~user/ --> ~user
|
|
</pre>
|
|
<p>
|
|
The output will be the same irrespective of the machine that the code is running on.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>fileName</code> - the fileName to query, null returns null</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>the path of the file, an empty string if none exists, null if invalid</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="getName-java.lang.String-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>getName</h4>
|
|
<pre>public static <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> getName(<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> fileName)</pre>
|
|
<div class="block">Gets the name minus the path from a full fileName.
|
|
<p>
|
|
This method will handle a file in either Unix or Windows format.
|
|
The text after the last forward or backslash is returned.
|
|
<pre>
|
|
a/b/c.txt --> c.txt
|
|
a.txt --> a.txt
|
|
a/b/c --> c
|
|
a/b/c/ --> ""
|
|
</pre>
|
|
<p>
|
|
The output will be the same irrespective of the machine that the code is running on.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>fileName</code> - the fileName to query, null returns null</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>the name of the file without the path, or an empty string if none exists.
|
|
Null bytes inside string will be removed</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="getBaseName-java.lang.String-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>getBaseName</h4>
|
|
<pre>public static <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> getBaseName(<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> fileName)</pre>
|
|
<div class="block">Gets the base name, minus the full path and extension, from a full fileName.
|
|
<p>
|
|
This method will handle a file in either Unix or Windows format.
|
|
The text after the last forward or backslash and before the last dot is returned.
|
|
<pre>
|
|
a/b/c.txt --> c
|
|
a.txt --> a
|
|
a/b/c --> c
|
|
a/b/c/ --> ""
|
|
</pre>
|
|
<p>
|
|
The output will be the same irrespective of the machine that the code is running on.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>fileName</code> - the fileName to query, null returns null</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>the name of the file without the path, or an empty string if none exists. Null bytes inside string
|
|
will be removed</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="getExtension-java.lang.String-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>getExtension</h4>
|
|
<pre>public static <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> getExtension(<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> fileName)
|
|
throws <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></pre>
|
|
<div class="block">Gets the extension of a fileName.
|
|
<p>
|
|
This method returns the textual part of the fileName after the last dot.
|
|
There must be no directory separator after the dot.
|
|
<pre>
|
|
foo.txt --> "txt"
|
|
a/b/c.jpg --> "jpg"
|
|
a/b.txt/c --> ""
|
|
a/b/c --> ""
|
|
</pre>
|
|
<p>
|
|
The output will be the same irrespective of the machine that the code is running on, with the
|
|
exception of a possible <a href="https://docs.oracle.com/javase/7/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang"><code>IllegalArgumentException</code></a> on Windows (see below).
|
|
</p>
|
|
<p>
|
|
<b>Note:</b> This method used to have a hidden problem for names like "foo.exe:bar.txt".
|
|
In this case, the name wouldn't be the name of a file, but the identifier of an
|
|
alternate data stream (bar.txt) on the file foo.exe. The method used to return
|
|
".txt" here, which would be misleading. Commons IO 2.7, and later versions, are throwing
|
|
an <a href="https://docs.oracle.com/javase/7/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang"><code>IllegalArgumentException</code></a> for names like this.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>fileName</code> - the fileName to retrieve the extension of.</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>the extension of the file or an empty string if none exists or <code>null</code>
|
|
if the fileName is <code>null</code>.</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> - <b>Windows only:</b> The fileName parameter is, in fact,
|
|
the identifier of an Alternate Data Stream, for example "foo.exe:bar.txt".</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="removeExtension-java.lang.String-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>removeExtension</h4>
|
|
<pre>public static <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> removeExtension(<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> fileName)</pre>
|
|
<div class="block">Removes the extension from a fileName.
|
|
<p>
|
|
This method returns the textual part of the fileName before the last dot.
|
|
There must be no directory separator after the dot.
|
|
<pre>
|
|
foo.txt --> foo
|
|
a\b\c.jpg --> a\b\c
|
|
a\b\c --> a\b\c
|
|
a.b\c --> a.b\c
|
|
</pre>
|
|
<p>
|
|
The output will be the same irrespective of the machine that the code is running on.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>fileName</code> - the fileName to query, null returns null</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>the fileName minus the extension</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="equals-java.lang.String-java.lang.String-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>equals</h4>
|
|
<pre>public static boolean equals(<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> fileName1,
|
|
<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> fileName2)</pre>
|
|
<div class="block">Checks whether two fileNames are equal exactly.
|
|
<p>
|
|
No processing is performed on the fileNames other than comparison,
|
|
thus this is merely a null-safe case-sensitive equals.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>fileName1</code> - the first fileName to query, may be null</dd>
|
|
<dd><code>fileName2</code> - the second fileName to query, may be null</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>true if the fileNames are equal, null equals null</dd>
|
|
<dt><span class="seeLabel">See Also:</span></dt>
|
|
<dd><a href="../../../../org/apache/commons/io/IOCase.html#SENSITIVE"><code>IOCase.SENSITIVE</code></a></dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="equalsOnSystem-java.lang.String-java.lang.String-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>equalsOnSystem</h4>
|
|
<pre>public static boolean equalsOnSystem(<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> fileName1,
|
|
<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> fileName2)</pre>
|
|
<div class="block">Checks whether two fileNames are equal using the case rules of the system.
|
|
<p>
|
|
No processing is performed on the fileNames other than comparison.
|
|
The check is case-sensitive on Unix and case-insensitive on Windows.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>fileName1</code> - the first fileName to query, may be null</dd>
|
|
<dd><code>fileName2</code> - the second fileName to query, may be null</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>true if the fileNames are equal, null equals null</dd>
|
|
<dt><span class="seeLabel">See Also:</span></dt>
|
|
<dd><a href="../../../../org/apache/commons/io/IOCase.html#SYSTEM"><code>IOCase.SYSTEM</code></a></dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="equalsNormalized-java.lang.String-java.lang.String-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>equalsNormalized</h4>
|
|
<pre>public static boolean equalsNormalized(<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> fileName1,
|
|
<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> fileName2)</pre>
|
|
<div class="block">Checks whether two fileNames are equal after both have been normalized.
|
|
<p>
|
|
Both fileNames are first passed to <a href="../../../../org/apache/commons/io/FilenameUtils.html#normalize-java.lang.String-"><code>normalize(String)</code></a>.
|
|
The check is then performed in a case-sensitive manner.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>fileName1</code> - the first fileName to query, may be null</dd>
|
|
<dd><code>fileName2</code> - the second fileName to query, may be null</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>true if the fileNames are equal, null equals null</dd>
|
|
<dt><span class="seeLabel">See Also:</span></dt>
|
|
<dd><a href="../../../../org/apache/commons/io/IOCase.html#SENSITIVE"><code>IOCase.SENSITIVE</code></a></dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="equalsNormalizedOnSystem-java.lang.String-java.lang.String-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>equalsNormalizedOnSystem</h4>
|
|
<pre>public static boolean equalsNormalizedOnSystem(<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> fileName1,
|
|
<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> fileName2)</pre>
|
|
<div class="block">Checks whether two fileNames are equal after both have been normalized
|
|
and using the case rules of the system.
|
|
<p>
|
|
Both fileNames are first passed to <a href="../../../../org/apache/commons/io/FilenameUtils.html#normalize-java.lang.String-"><code>normalize(String)</code></a>.
|
|
The check is then performed case-sensitive on Unix and
|
|
case-insensitive on Windows.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>fileName1</code> - the first fileName to query, may be null</dd>
|
|
<dd><code>fileName2</code> - the second fileName to query, may be null</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>true if the fileNames are equal, null equals null</dd>
|
|
<dt><span class="seeLabel">See Also:</span></dt>
|
|
<dd><a href="../../../../org/apache/commons/io/IOCase.html#SYSTEM"><code>IOCase.SYSTEM</code></a></dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="equals-java.lang.String-java.lang.String-boolean-org.apache.commons.io.IOCase-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>equals</h4>
|
|
<pre>public static boolean equals(<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> fileName1,
|
|
<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> fileName2,
|
|
boolean normalized,
|
|
<a href="../../../../org/apache/commons/io/IOCase.html" title="enum in org.apache.commons.io">IOCase</a> caseSensitivity)</pre>
|
|
<div class="block">Checks whether two fileNames are equal, optionally normalizing and providing
|
|
control over the case-sensitivity.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>fileName1</code> - the first fileName to query, may be null</dd>
|
|
<dd><code>fileName2</code> - the second fileName to query, may be null</dd>
|
|
<dd><code>normalized</code> - whether to normalize the fileNames</dd>
|
|
<dd><code>caseSensitivity</code> - what case sensitivity rule to use, null means case-sensitive</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>true if the fileNames are equal, null equals null</dd>
|
|
<dt><span class="simpleTagLabel">Since:</span></dt>
|
|
<dd>1.3</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="isExtension-java.lang.String-java.lang.String-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>isExtension</h4>
|
|
<pre>public static boolean isExtension(<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> fileName,
|
|
<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> extension)</pre>
|
|
<div class="block">Checks whether the extension of the fileName is that specified.
|
|
<p>
|
|
This method obtains the extension as the textual part of the fileName
|
|
after the last dot. There must be no directory separator after the dot.
|
|
The extension check is case-sensitive on all platforms.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>fileName</code> - the fileName to query, null returns false</dd>
|
|
<dd><code>extension</code> - the extension to check for, null or empty checks for no extension</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>true if the fileName has the specified extension</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 supplied fileName contains null bytes</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="isExtension-java.lang.String-java.lang.String...-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>isExtension</h4>
|
|
<pre>public static boolean isExtension(<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> fileName,
|
|
<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>... extensions)</pre>
|
|
<div class="block">Checks whether the extension of the fileName is one of those specified.
|
|
<p>
|
|
This method obtains the extension as the textual part of the fileName
|
|
after the last dot. There must be no directory separator after the dot.
|
|
The extension check is case-sensitive on all platforms.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>fileName</code> - the fileName to query, null returns false</dd>
|
|
<dd><code>extensions</code> - the extensions to check for, null checks for no extension</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>true if the fileName is one of the extensions</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 supplied fileName contains null bytes</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="isExtension-java.lang.String-java.util.Collection-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>isExtension</h4>
|
|
<pre>public static boolean isExtension(<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> fileName,
|
|
<a href="https://docs.oracle.com/javase/7/docs/api/java/util/Collection.html?is-external=true" title="class or interface in java.util">Collection</a><<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>> extensions)</pre>
|
|
<div class="block">Checks whether the extension of the fileName is one of those specified.
|
|
<p>
|
|
This method obtains the extension as the textual part of the fileName
|
|
after the last dot. There must be no directory separator after the dot.
|
|
The extension check is case-sensitive on all platforms.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>fileName</code> - the fileName to query, null returns false</dd>
|
|
<dd><code>extensions</code> - the extensions to check for, null checks for no extension</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>true if the fileName is one of the extensions</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 supplied fileName contains null bytes</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="wildcardMatch-java.lang.String-java.lang.String-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>wildcardMatch</h4>
|
|
<pre>public static boolean wildcardMatch(<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> fileName,
|
|
<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> wildcardMatcher)</pre>
|
|
<div class="block">Checks a fileName to see if it matches the specified wildcard matcher,
|
|
always testing case-sensitive.
|
|
<p>
|
|
The wildcard matcher uses the characters '?' and '*' to represent a
|
|
single or multiple (zero or more) wildcard characters.
|
|
This is the same as often found on Dos/Unix command lines.
|
|
The check is case-sensitive always.
|
|
<pre>
|
|
wildcardMatch("c.txt", "*.txt") --> true
|
|
wildcardMatch("c.txt", "*.jpg") --> false
|
|
wildcardMatch("a/b/c.txt", "a/b/*") --> true
|
|
wildcardMatch("c.txt", "*.???") --> true
|
|
wildcardMatch("c.txt", "*.????") --> false
|
|
</pre>
|
|
N.B. the sequence "*?" does not work properly at present in match strings.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>fileName</code> - the fileName to match on</dd>
|
|
<dd><code>wildcardMatcher</code> - the wildcard string to match against</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>true if the fileName matches the wildcard string</dd>
|
|
<dt><span class="seeLabel">See Also:</span></dt>
|
|
<dd><a href="../../../../org/apache/commons/io/IOCase.html#SENSITIVE"><code>IOCase.SENSITIVE</code></a></dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="wildcardMatchOnSystem-java.lang.String-java.lang.String-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>wildcardMatchOnSystem</h4>
|
|
<pre>public static boolean wildcardMatchOnSystem(<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> fileName,
|
|
<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> wildcardMatcher)</pre>
|
|
<div class="block">Checks a fileName to see if it matches the specified wildcard matcher
|
|
using the case rules of the system.
|
|
<p>
|
|
The wildcard matcher uses the characters '?' and '*' to represent a
|
|
single or multiple (zero or more) wildcard characters.
|
|
This is the same as often found on Dos/Unix command lines.
|
|
The check is case-sensitive on Unix and case-insensitive on Windows.
|
|
<pre>
|
|
wildcardMatch("c.txt", "*.txt") --> true
|
|
wildcardMatch("c.txt", "*.jpg") --> false
|
|
wildcardMatch("a/b/c.txt", "a/b/*") --> true
|
|
wildcardMatch("c.txt", "*.???") --> true
|
|
wildcardMatch("c.txt", "*.????") --> false
|
|
</pre>
|
|
N.B. the sequence "*?" does not work properly at present in match strings.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>fileName</code> - the fileName to match on</dd>
|
|
<dd><code>wildcardMatcher</code> - the wildcard string to match against</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>true if the fileName matches the wildcard string</dd>
|
|
<dt><span class="seeLabel">See Also:</span></dt>
|
|
<dd><a href="../../../../org/apache/commons/io/IOCase.html#SYSTEM"><code>IOCase.SYSTEM</code></a></dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a name="wildcardMatch-java.lang.String-java.lang.String-org.apache.commons.io.IOCase-">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockListLast">
|
|
<li class="blockList">
|
|
<h4>wildcardMatch</h4>
|
|
<pre>public static boolean wildcardMatch(<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> fileName,
|
|
<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> wildcardMatcher,
|
|
<a href="../../../../org/apache/commons/io/IOCase.html" title="enum in org.apache.commons.io">IOCase</a> caseSensitivity)</pre>
|
|
<div class="block">Checks a fileName to see if it matches the specified wildcard matcher
|
|
allowing control over case-sensitivity.
|
|
<p>
|
|
The wildcard matcher uses the characters '?' and '*' to represent a
|
|
single or multiple (zero or more) wildcard characters.
|
|
N.B. the sequence "*?" does not work properly at present in match strings.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>fileName</code> - the fileName to match on</dd>
|
|
<dd><code>wildcardMatcher</code> - the wildcard string to match against</dd>
|
|
<dd><code>caseSensitivity</code> - what case sensitivity rule to use, null means case-sensitive</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>true if the fileName matches the wildcard string</dd>
|
|
<dt><span class="simpleTagLabel">Since:</span></dt>
|
|
<dd>1.3</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/FilenameUtils.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/FileExistsException.html" title="class in org.apache.commons.io"><span class="typeNameLink">Prev Class</span></a></li>
|
|
<li><a href="../../../../org/apache/commons/io/FileSystem.html" title="enum 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/FilenameUtils.html" target="_top">Frames</a></li>
|
|
<li><a href="FilenameUtils.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><a href="#field.summary">Field</a> | </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><a href="#field.detail">Field</a> | </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>
|