DirectoryWalker.html 57 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <!-- NewPage -->
  3. <html lang="de">
  4. <head>
  5. <!-- Generated by javadoc -->
  6. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  7. <title>DirectoryWalker (Apache Commons IO 2.6 API)</title>
  8. <link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">
  9. <script type="text/javascript" src="../../../../script.js"></script>
  10. </head>
  11. <body>
  12. <script type="text/javascript"><!--
  13. try {
  14. if (location.href.indexOf('is-external=true') == -1) {
  15. parent.document.title="DirectoryWalker (Apache Commons IO 2.6 API)";
  16. }
  17. }
  18. catch(err) {
  19. }
  20. //-->
  21. var methods = {"i0":10,"i1":10,"i2":10,"i3":10,"i4":10,"i5":10,"i6":10,"i7":10,"i8":10,"i9":10,"i10":10,"i11":10};
  22. var tabs = {65535:["t0","All Methods"],2:["t2","Instance Methods"],8:["t4","Concrete Methods"]};
  23. var altColor = "altColor";
  24. var rowColor = "rowColor";
  25. var tableTab = "tableTab";
  26. var activeTableTab = "activeTableTab";
  27. </script>
  28. <noscript>
  29. <div>JavaScript is disabled on your browser.</div>
  30. </noscript>
  31. <!-- ========= START OF TOP NAVBAR ======= -->
  32. <div class="topNav"><a name="navbar.top">
  33. <!-- -->
  34. </a>
  35. <div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
  36. <a name="navbar.top.firstrow">
  37. <!-- -->
  38. </a>
  39. <ul class="navList" title="Navigation">
  40. <li><a href="../../../../overview-summary.html">Overview</a></li>
  41. <li><a href="package-summary.html">Package</a></li>
  42. <li class="navBarCell1Rev">Class</li>
  43. <li><a href="class-use/DirectoryWalker.html">Use</a></li>
  44. <li><a href="package-tree.html">Tree</a></li>
  45. <li><a href="../../../../deprecated-list.html">Deprecated</a></li>
  46. <li><a href="../../../../index-all.html">Index</a></li>
  47. <li><a href="../../../../help-doc.html">Help</a></li>
  48. </ul>
  49. </div>
  50. <div class="subNav">
  51. <ul class="navList">
  52. <li><a href="../../../../org/apache/commons/io/CopyUtils.html" title="class in org.apache.commons.io"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
  53. <li><a href="../../../../org/apache/commons/io/DirectoryWalker.CancelException.html" title="class in org.apache.commons.io"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
  54. </ul>
  55. <ul class="navList">
  56. <li><a href="../../../../index.html?org/apache/commons/io/DirectoryWalker.html" target="_top">Frames</a></li>
  57. <li><a href="DirectoryWalker.html" target="_top">No&nbsp;Frames</a></li>
  58. </ul>
  59. <ul class="navList" id="allclasses_navbar_top">
  60. <li><a href="../../../../allclasses-noframe.html">All&nbsp;Classes</a></li>
  61. </ul>
  62. <div>
  63. <script type="text/javascript"><!--
  64. allClassesLink = document.getElementById("allclasses_navbar_top");
  65. if(window==top) {
  66. allClassesLink.style.display = "block";
  67. }
  68. else {
  69. allClassesLink.style.display = "none";
  70. }
  71. //-->
  72. </script>
  73. </div>
  74. <div>
  75. <ul class="subNavList">
  76. <li>Summary:&nbsp;</li>
  77. <li><a href="#nested.class.summary">Nested</a>&nbsp;|&nbsp;</li>
  78. <li>Field&nbsp;|&nbsp;</li>
  79. <li><a href="#constructor.summary">Constr</a>&nbsp;|&nbsp;</li>
  80. <li><a href="#method.summary">Method</a></li>
  81. </ul>
  82. <ul class="subNavList">
  83. <li>Detail:&nbsp;</li>
  84. <li>Field&nbsp;|&nbsp;</li>
  85. <li><a href="#constructor.detail">Constr</a>&nbsp;|&nbsp;</li>
  86. <li><a href="#method.detail">Method</a></li>
  87. </ul>
  88. </div>
  89. <a name="skip.navbar.top">
  90. <!-- -->
  91. </a></div>
  92. <!-- ========= END OF TOP NAVBAR ========= -->
  93. <!-- ======== START OF CLASS DATA ======== -->
  94. <div class="header">
  95. <div class="subTitle">org.apache.commons.io</div>
  96. <h2 title="Class DirectoryWalker" class="title">Class DirectoryWalker&lt;T&gt;</h2>
  97. </div>
  98. <div class="contentContainer">
  99. <ul class="inheritance">
  100. <li><a href="http://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>
  101. <li>
  102. <ul class="inheritance">
  103. <li>org.apache.commons.io.DirectoryWalker&lt;T&gt;</li>
  104. </ul>
  105. </li>
  106. </ul>
  107. <div class="description">
  108. <ul class="blockList">
  109. <li class="blockList">
  110. <hr>
  111. <br>
  112. <pre>public abstract class <span class="typeNameLabel">DirectoryWalker&lt;T&gt;</span>
  113. extends <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></pre>
  114. <div class="block">Abstract class that walks through a directory hierarchy and provides
  115. subclasses with convenient hooks to add specific behaviour.
  116. <p>
  117. This class operates with a <a href="http://docs.oracle.com/javase/7/docs/api/java/io/FileFilter.html?is-external=true" title="class or interface in java.io"><code>FileFilter</code></a> and maximum depth to
  118. limit the files and directories visited.
  119. Commons IO supplies many common filter implementations in the
  120. <a href="filefilter/package-summary.html"> filefilter</a> package.
  121. <p>
  122. The following sections describe:
  123. <ul>
  124. <li><a href="#example">1. Example Implementation</a> - example
  125. <code>FileCleaner</code> implementation.</li>
  126. <li><a href="#filter">2. Filter Example</a> - using
  127. <a href="http://docs.oracle.com/javase/7/docs/api/java/io/FileFilter.html?is-external=true" title="class or interface in java.io"><code>FileFilter</code></a>(s) with <code>DirectoryWalker</code>.</li>
  128. <li><a href="#cancel">3. Cancellation</a> - how to implement cancellation
  129. behaviour.</li>
  130. </ul>
  131. <a name="example"></a>
  132. <h3>1. Example Implementation</h3>
  133. There are many possible extensions, for example, to delete all
  134. files and '.svn' directories, and return a list of deleted files:
  135. <pre>
  136. public class FileCleaner extends DirectoryWalker {
  137. public FileCleaner() {
  138. super();
  139. }
  140. public List clean(File startDirectory) {
  141. List results = new ArrayList();
  142. walk(startDirectory, results);
  143. return results;
  144. }
  145. protected boolean handleDirectory(File directory, int depth, Collection results) {
  146. // delete svn directories and then skip
  147. if (".svn".equals(directory.getName())) {
  148. directory.delete();
  149. return false;
  150. } else {
  151. return true;
  152. }
  153. }
  154. protected void handleFile(File file, int depth, Collection results) {
  155. // delete file and add to list of deleted
  156. file.delete();
  157. results.add(file);
  158. }
  159. }
  160. </pre>
  161. <a name="filter"></a>
  162. <h3>2. Filter Example</h3>
  163. Choosing which directories and files to process can be a key aspect
  164. of using this class. This information can be setup in three ways,
  165. via three different constructors.
  166. <p>
  167. The first option is to visit all directories and files.
  168. This is achieved via the no-args constructor.
  169. <p>
  170. The second constructor option is to supply a single <a href="http://docs.oracle.com/javase/7/docs/api/java/io/FileFilter.html?is-external=true" title="class or interface in java.io"><code>FileFilter</code></a>
  171. that describes the files and directories to visit. Care must be taken
  172. with this option as the same filter is used for both directories
  173. and files.
  174. <p>
  175. For example, if you wanted all directories which are not hidden
  176. and files which end in ".txt":
  177. <pre>
  178. public class FooDirectoryWalker extends DirectoryWalker {
  179. public FooDirectoryWalker(FileFilter filter) {
  180. super(filter, -1);
  181. }
  182. }
  183. // Build up the filters and create the walker
  184. // Create a filter for Non-hidden directories
  185. IOFileFilter fooDirFilter =
  186. FileFilterUtils.andFileFilter(FileFilterUtils.directoryFileFilter,
  187. HiddenFileFilter.VISIBLE);
  188. // Create a filter for Files ending in ".txt"
  189. IOFileFilter fooFileFilter =
  190. FileFilterUtils.andFileFilter(FileFilterUtils.fileFileFilter,
  191. FileFilterUtils.suffixFileFilter(".txt"));
  192. // Combine the directory and file filters using an OR condition
  193. java.io.FileFilter fooFilter =
  194. FileFilterUtils.orFileFilter(fooDirFilter, fooFileFilter);
  195. // Use the filter to construct a DirectoryWalker implementation
  196. FooDirectoryWalker walker = new FooDirectoryWalker(fooFilter);
  197. </pre>
  198. <p>
  199. The third constructor option is to specify separate filters, one for
  200. directories and one for files. These are combined internally to form
  201. the correct <code>FileFilter</code>, something which is very easy to
  202. get wrong when attempted manually, particularly when trying to
  203. express constructs like 'any file in directories named docs'.
  204. <p>
  205. For example, if you wanted all directories which are not hidden
  206. and files which end in ".txt":
  207. <pre>
  208. public class FooDirectoryWalker extends DirectoryWalker {
  209. public FooDirectoryWalker(IOFileFilter dirFilter, IOFileFilter fileFilter) {
  210. super(dirFilter, fileFilter, -1);
  211. }
  212. }
  213. // Use the filters to construct the walker
  214. FooDirectoryWalker walker = new FooDirectoryWalker(
  215. HiddenFileFilter.VISIBLE,
  216. FileFilterUtils.suffixFileFilter(".txt"),
  217. );
  218. </pre>
  219. This is much simpler than the previous example, and is why it is the preferred
  220. option for filtering.
  221. <a name="cancel"></a>
  222. <h3>3. Cancellation</h3>
  223. The DirectoryWalker contains some of the logic required for cancel processing.
  224. Subclasses must complete the implementation.
  225. <p>
  226. What <code>DirectoryWalker</code> does provide for cancellation is:
  227. <ul>
  228. <li><a href="../../../../org/apache/commons/io/DirectoryWalker.CancelException.html" title="class in org.apache.commons.io"><code>DirectoryWalker.CancelException</code></a> which can be thrown in any of the
  229. <i>lifecycle</i> methods to stop processing.</li>
  230. <li>The <code>walk()</code> method traps thrown <a href="../../../../org/apache/commons/io/DirectoryWalker.CancelException.html" title="class in org.apache.commons.io"><code>DirectoryWalker.CancelException</code></a>
  231. and calls the <code>handleCancelled()</code> method, providing
  232. a place for custom cancel processing.</li>
  233. </ul>
  234. <p>
  235. Implementations need to provide:
  236. <ul>
  237. <li>The decision logic on whether to cancel processing or not.</li>
  238. <li>Constructing and throwing a <a href="../../../../org/apache/commons/io/DirectoryWalker.CancelException.html" title="class in org.apache.commons.io"><code>DirectoryWalker.CancelException</code></a>.</li>
  239. <li>Custom cancel processing in the <code>handleCancelled()</code> method.
  240. </ul>
  241. <p>
  242. Two possible scenarios are envisaged for cancellation:
  243. <ul>
  244. <li><a href="#external">3.1 External / Multi-threaded</a> - cancellation being
  245. decided/initiated by an external process.</li>
  246. <li><a href="#internal">3.2 Internal</a> - cancellation being decided/initiated
  247. from within a DirectoryWalker implementation.</li>
  248. </ul>
  249. <p>
  250. The following sections provide example implementations for these two different
  251. scenarios.
  252. <a name="external"></a>
  253. <h4>3.1 External / Multi-threaded</h4>
  254. This example provides a public <code>cancel()</code> method that can be
  255. called by another thread to stop the processing. A typical example use-case
  256. would be a cancel button on a GUI. Calling this method sets a
  257. <a href="http://java.sun.com/docs/books/jls/second_edition/html/classes.doc.html#36930">
  258. volatile</a> flag to ensure it will work properly in a multi-threaded environment.
  259. The flag is returned by the <code>handleIsCancelled()</code> method, which
  260. will cause the walk to stop immediately. The <code>handleCancelled()</code>
  261. method will be the next, and last, callback method received once cancellation
  262. has occurred.
  263. <pre>
  264. public class FooDirectoryWalker extends DirectoryWalker {
  265. private volatile boolean cancelled = false;
  266. public void cancel() {
  267. cancelled = true;
  268. }
  269. protected boolean handleIsCancelled(File file, int depth, Collection results) {
  270. return cancelled;
  271. }
  272. protected void handleCancelled(File startDirectory, Collection results, CancelException cancel) {
  273. // implement processing required when a cancellation occurs
  274. }
  275. }
  276. </pre>
  277. <a name="internal"></a>
  278. <h4>3.2 Internal</h4>
  279. This shows an example of how internal cancellation processing could be implemented.
  280. <b>Note</b> the decision logic and throwing a <a href="../../../../org/apache/commons/io/DirectoryWalker.CancelException.html" title="class in org.apache.commons.io"><code>DirectoryWalker.CancelException</code></a> could be implemented
  281. in any of the <i>lifecycle</i> methods.
  282. <pre>
  283. public class BarDirectoryWalker extends DirectoryWalker {
  284. protected boolean handleDirectory(File directory, int depth, Collection results) throws IOException {
  285. // cancel if hidden directory
  286. if (directory.isHidden()) {
  287. throw new CancelException(file, depth);
  288. }
  289. return true;
  290. }
  291. protected void handleFile(File file, int depth, Collection results) throws IOException {
  292. // cancel if read-only file
  293. if (!file.canWrite()) {
  294. throw new CancelException(file, depth);
  295. }
  296. results.add(file);
  297. }
  298. protected void handleCancelled(File startDirectory, Collection results, CancelException cancel) {
  299. // implement processing required when a cancellation occurs
  300. }
  301. }
  302. </pre></div>
  303. <dl>
  304. <dt><span class="simpleTagLabel">Since:</span></dt>
  305. <dd>1.3</dd>
  306. <dt><span class="simpleTagLabel">Version:</span></dt>
  307. <dd>$Id$</dd>
  308. </dl>
  309. </li>
  310. </ul>
  311. </div>
  312. <div class="summary">
  313. <ul class="blockList">
  314. <li class="blockList">
  315. <!-- ======== NESTED CLASS SUMMARY ======== -->
  316. <ul class="blockList">
  317. <li class="blockList"><a name="nested.class.summary">
  318. <!-- -->
  319. </a>
  320. <h3>Nested Class Summary</h3>
  321. <table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Nested Class Summary table, listing nested classes, and an explanation">
  322. <caption><span>Nested Classes</span><span class="tabEnd">&nbsp;</span></caption>
  323. <tr>
  324. <th class="colFirst" scope="col">Modifier and Type</th>
  325. <th class="colLast" scope="col">Class and Description</th>
  326. </tr>
  327. <tr class="altColor">
  328. <td class="colFirst"><code>static class&nbsp;</code></td>
  329. <td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/commons/io/DirectoryWalker.CancelException.html" title="class in org.apache.commons.io">DirectoryWalker.CancelException</a></span></code>
  330. <div class="block">CancelException is thrown in DirectoryWalker to cancel the current
  331. processing.</div>
  332. </td>
  333. </tr>
  334. </table>
  335. </li>
  336. </ul>
  337. <!-- ======== CONSTRUCTOR SUMMARY ======== -->
  338. <ul class="blockList">
  339. <li class="blockList"><a name="constructor.summary">
  340. <!-- -->
  341. </a>
  342. <h3>Constructor Summary</h3>
  343. <table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Constructor Summary table, listing constructors, and an explanation">
  344. <caption><span>Constructors</span><span class="tabEnd">&nbsp;</span></caption>
  345. <tr>
  346. <th class="colFirst" scope="col">Modifier</th>
  347. <th class="colLast" scope="col">Constructor and Description</th>
  348. </tr>
  349. <tr class="altColor">
  350. <td class="colFirst"><code>protected </code></td>
  351. <td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/commons/io/DirectoryWalker.html#DirectoryWalker--">DirectoryWalker</a></span>()</code>
  352. <div class="block">Construct an instance with no filtering and unlimited <i>depth</i>.</div>
  353. </td>
  354. </tr>
  355. <tr class="rowColor">
  356. <td class="colFirst"><code>protected </code></td>
  357. <td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/commons/io/DirectoryWalker.html#DirectoryWalker-java.io.FileFilter-int-">DirectoryWalker</a></span>(<a href="http://docs.oracle.com/javase/7/docs/api/java/io/FileFilter.html?is-external=true" title="class or interface in java.io">FileFilter</a>&nbsp;filter,
  358. int&nbsp;depthLimit)</code>
  359. <div class="block">Construct an instance with a filter and limit the <i>depth</i> navigated to.</div>
  360. </td>
  361. </tr>
  362. <tr class="altColor">
  363. <td class="colFirst"><code>protected </code></td>
  364. <td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/commons/io/DirectoryWalker.html#DirectoryWalker-org.apache.commons.io.filefilter.IOFileFilter-org.apache.commons.io.filefilter.IOFileFilter-int-">DirectoryWalker</a></span>(<a href="../../../../org/apache/commons/io/filefilter/IOFileFilter.html" title="interface in org.apache.commons.io.filefilter">IOFileFilter</a>&nbsp;directoryFilter,
  365. <a href="../../../../org/apache/commons/io/filefilter/IOFileFilter.html" title="interface in org.apache.commons.io.filefilter">IOFileFilter</a>&nbsp;fileFilter,
  366. int&nbsp;depthLimit)</code>
  367. <div class="block">Construct an instance with a directory and a file filter and an optional
  368. limit on the <i>depth</i> navigated to.</div>
  369. </td>
  370. </tr>
  371. </table>
  372. </li>
  373. </ul>
  374. <!-- ========== METHOD SUMMARY =========== -->
  375. <ul class="blockList">
  376. <li class="blockList"><a name="method.summary">
  377. <!-- -->
  378. </a>
  379. <h3>Method Summary</h3>
  380. <table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
  381. <caption><span id="t0" class="activeTableTab"><span>All Methods</span><span class="tabEnd">&nbsp;</span></span><span id="t2" class="tableTab"><span><a href="javascript:show(2);">Instance Methods</a></span><span class="tabEnd">&nbsp;</span></span><span id="t4" class="tableTab"><span><a href="javascript:show(8);">Concrete Methods</a></span><span class="tabEnd">&nbsp;</span></span></caption>
  382. <tr>
  383. <th class="colFirst" scope="col">Modifier and Type</th>
  384. <th class="colLast" scope="col">Method and Description</th>
  385. </tr>
  386. <tr id="i0" class="altColor">
  387. <td class="colFirst"><code>protected void</code></td>
  388. <td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/commons/io/DirectoryWalker.html#checkIfCancelled-java.io.File-int-java.util.Collection-">checkIfCancelled</a></span>(<a href="http://docs.oracle.com/javase/7/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</a>&nbsp;file,
  389. int&nbsp;depth,
  390. <a href="http://docs.oracle.com/javase/7/docs/api/java/util/Collection.html?is-external=true" title="class or interface in java.util">Collection</a>&lt;<a href="../../../../org/apache/commons/io/DirectoryWalker.html" title="type parameter in DirectoryWalker">T</a>&gt;&nbsp;results)</code>
  391. <div class="block">Checks whether the walk has been cancelled by calling <a href="../../../../org/apache/commons/io/DirectoryWalker.html#handleIsCancelled-java.io.File-int-java.util.Collection-"><code>handleIsCancelled(java.io.File, int, java.util.Collection&lt;T&gt;)</code></a>,
  392. throwing a <code>CancelException</code> if it has.</div>
  393. </td>
  394. </tr>
  395. <tr id="i1" class="rowColor">
  396. <td class="colFirst"><code>protected <a href="http://docs.oracle.com/javase/7/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</a>[]</code></td>
  397. <td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/commons/io/DirectoryWalker.html#filterDirectoryContents-java.io.File-int-java.io.File:A-">filterDirectoryContents</a></span>(<a href="http://docs.oracle.com/javase/7/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</a>&nbsp;directory,
  398. int&nbsp;depth,
  399. <a href="http://docs.oracle.com/javase/7/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</a>[]&nbsp;files)</code>
  400. <div class="block">Overridable callback method invoked with the contents of each directory.</div>
  401. </td>
  402. </tr>
  403. <tr id="i2" class="altColor">
  404. <td class="colFirst"><code>protected void</code></td>
  405. <td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/commons/io/DirectoryWalker.html#handleCancelled-java.io.File-java.util.Collection-org.apache.commons.io.DirectoryWalker.CancelException-">handleCancelled</a></span>(<a href="http://docs.oracle.com/javase/7/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</a>&nbsp;startDirectory,
  406. <a href="http://docs.oracle.com/javase/7/docs/api/java/util/Collection.html?is-external=true" title="class or interface in java.util">Collection</a>&lt;<a href="../../../../org/apache/commons/io/DirectoryWalker.html" title="type parameter in DirectoryWalker">T</a>&gt;&nbsp;results,
  407. <a href="../../../../org/apache/commons/io/DirectoryWalker.CancelException.html" title="class in org.apache.commons.io">DirectoryWalker.CancelException</a>&nbsp;cancel)</code>
  408. <div class="block">Overridable callback method invoked when the operation is cancelled.</div>
  409. </td>
  410. </tr>
  411. <tr id="i3" class="rowColor">
  412. <td class="colFirst"><code>protected boolean</code></td>
  413. <td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/commons/io/DirectoryWalker.html#handleDirectory-java.io.File-int-java.util.Collection-">handleDirectory</a></span>(<a href="http://docs.oracle.com/javase/7/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</a>&nbsp;directory,
  414. int&nbsp;depth,
  415. <a href="http://docs.oracle.com/javase/7/docs/api/java/util/Collection.html?is-external=true" title="class or interface in java.util">Collection</a>&lt;<a href="../../../../org/apache/commons/io/DirectoryWalker.html" title="type parameter in DirectoryWalker">T</a>&gt;&nbsp;results)</code>
  416. <div class="block">Overridable callback method invoked to determine if a directory should be processed.</div>
  417. </td>
  418. </tr>
  419. <tr id="i4" class="altColor">
  420. <td class="colFirst"><code>protected void</code></td>
  421. <td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/commons/io/DirectoryWalker.html#handleDirectoryEnd-java.io.File-int-java.util.Collection-">handleDirectoryEnd</a></span>(<a href="http://docs.oracle.com/javase/7/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</a>&nbsp;directory,
  422. int&nbsp;depth,
  423. <a href="http://docs.oracle.com/javase/7/docs/api/java/util/Collection.html?is-external=true" title="class or interface in java.util">Collection</a>&lt;<a href="../../../../org/apache/commons/io/DirectoryWalker.html" title="type parameter in DirectoryWalker">T</a>&gt;&nbsp;results)</code>
  424. <div class="block">Overridable callback method invoked at the end of processing each directory.</div>
  425. </td>
  426. </tr>
  427. <tr id="i5" class="rowColor">
  428. <td class="colFirst"><code>protected void</code></td>
  429. <td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/commons/io/DirectoryWalker.html#handleDirectoryStart-java.io.File-int-java.util.Collection-">handleDirectoryStart</a></span>(<a href="http://docs.oracle.com/javase/7/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</a>&nbsp;directory,
  430. int&nbsp;depth,
  431. <a href="http://docs.oracle.com/javase/7/docs/api/java/util/Collection.html?is-external=true" title="class or interface in java.util">Collection</a>&lt;<a href="../../../../org/apache/commons/io/DirectoryWalker.html" title="type parameter in DirectoryWalker">T</a>&gt;&nbsp;results)</code>
  432. <div class="block">Overridable callback method invoked at the start of processing each directory.</div>
  433. </td>
  434. </tr>
  435. <tr id="i6" class="altColor">
  436. <td class="colFirst"><code>protected void</code></td>
  437. <td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/commons/io/DirectoryWalker.html#handleEnd-java.util.Collection-">handleEnd</a></span>(<a href="http://docs.oracle.com/javase/7/docs/api/java/util/Collection.html?is-external=true" title="class or interface in java.util">Collection</a>&lt;<a href="../../../../org/apache/commons/io/DirectoryWalker.html" title="type parameter in DirectoryWalker">T</a>&gt;&nbsp;results)</code>
  438. <div class="block">Overridable callback method invoked at the end of processing.</div>
  439. </td>
  440. </tr>
  441. <tr id="i7" class="rowColor">
  442. <td class="colFirst"><code>protected void</code></td>
  443. <td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/commons/io/DirectoryWalker.html#handleFile-java.io.File-int-java.util.Collection-">handleFile</a></span>(<a href="http://docs.oracle.com/javase/7/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</a>&nbsp;file,
  444. int&nbsp;depth,
  445. <a href="http://docs.oracle.com/javase/7/docs/api/java/util/Collection.html?is-external=true" title="class or interface in java.util">Collection</a>&lt;<a href="../../../../org/apache/commons/io/DirectoryWalker.html" title="type parameter in DirectoryWalker">T</a>&gt;&nbsp;results)</code>
  446. <div class="block">Overridable callback method invoked for each (non-directory) file.</div>
  447. </td>
  448. </tr>
  449. <tr id="i8" class="altColor">
  450. <td class="colFirst"><code>protected boolean</code></td>
  451. <td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/commons/io/DirectoryWalker.html#handleIsCancelled-java.io.File-int-java.util.Collection-">handleIsCancelled</a></span>(<a href="http://docs.oracle.com/javase/7/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</a>&nbsp;file,
  452. int&nbsp;depth,
  453. <a href="http://docs.oracle.com/javase/7/docs/api/java/util/Collection.html?is-external=true" title="class or interface in java.util">Collection</a>&lt;<a href="../../../../org/apache/commons/io/DirectoryWalker.html" title="type parameter in DirectoryWalker">T</a>&gt;&nbsp;results)</code>
  454. <div class="block">Overridable callback method invoked to determine if the entire walk
  455. operation should be immediately cancelled.</div>
  456. </td>
  457. </tr>
  458. <tr id="i9" class="rowColor">
  459. <td class="colFirst"><code>protected void</code></td>
  460. <td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/commons/io/DirectoryWalker.html#handleRestricted-java.io.File-int-java.util.Collection-">handleRestricted</a></span>(<a href="http://docs.oracle.com/javase/7/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</a>&nbsp;directory,
  461. int&nbsp;depth,
  462. <a href="http://docs.oracle.com/javase/7/docs/api/java/util/Collection.html?is-external=true" title="class or interface in java.util">Collection</a>&lt;<a href="../../../../org/apache/commons/io/DirectoryWalker.html" title="type parameter in DirectoryWalker">T</a>&gt;&nbsp;results)</code>
  463. <div class="block">Overridable callback method invoked for each restricted directory.</div>
  464. </td>
  465. </tr>
  466. <tr id="i10" class="altColor">
  467. <td class="colFirst"><code>protected void</code></td>
  468. <td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/commons/io/DirectoryWalker.html#handleStart-java.io.File-java.util.Collection-">handleStart</a></span>(<a href="http://docs.oracle.com/javase/7/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</a>&nbsp;startDirectory,
  469. <a href="http://docs.oracle.com/javase/7/docs/api/java/util/Collection.html?is-external=true" title="class or interface in java.util">Collection</a>&lt;<a href="../../../../org/apache/commons/io/DirectoryWalker.html" title="type parameter in DirectoryWalker">T</a>&gt;&nbsp;results)</code>
  470. <div class="block">Overridable callback method invoked at the start of processing.</div>
  471. </td>
  472. </tr>
  473. <tr id="i11" class="rowColor">
  474. <td class="colFirst"><code>protected void</code></td>
  475. <td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/commons/io/DirectoryWalker.html#walk-java.io.File-java.util.Collection-">walk</a></span>(<a href="http://docs.oracle.com/javase/7/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</a>&nbsp;startDirectory,
  476. <a href="http://docs.oracle.com/javase/7/docs/api/java/util/Collection.html?is-external=true" title="class or interface in java.util">Collection</a>&lt;<a href="../../../../org/apache/commons/io/DirectoryWalker.html" title="type parameter in DirectoryWalker">T</a>&gt;&nbsp;results)</code>
  477. <div class="block">Internal method that walks the directory hierarchy in a depth-first manner.</div>
  478. </td>
  479. </tr>
  480. </table>
  481. <ul class="blockList">
  482. <li class="blockList"><a name="methods.inherited.from.class.java.lang.Object">
  483. <!-- -->
  484. </a>
  485. <h3>Methods inherited from class&nbsp;java.lang.<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></h3>
  486. <code><a href="http://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="http://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="http://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="http://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="http://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="http://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="http://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="http://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="http://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="http://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="http://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>
  487. </ul>
  488. </li>
  489. </ul>
  490. </li>
  491. </ul>
  492. </div>
  493. <div class="details">
  494. <ul class="blockList">
  495. <li class="blockList">
  496. <!-- ========= CONSTRUCTOR DETAIL ======== -->
  497. <ul class="blockList">
  498. <li class="blockList"><a name="constructor.detail">
  499. <!-- -->
  500. </a>
  501. <h3>Constructor Detail</h3>
  502. <a name="DirectoryWalker--">
  503. <!-- -->
  504. </a>
  505. <ul class="blockList">
  506. <li class="blockList">
  507. <h4>DirectoryWalker</h4>
  508. <pre>protected&nbsp;DirectoryWalker()</pre>
  509. <div class="block">Construct an instance with no filtering and unlimited <i>depth</i>.</div>
  510. </li>
  511. </ul>
  512. <a name="DirectoryWalker-java.io.FileFilter-int-">
  513. <!-- -->
  514. </a>
  515. <ul class="blockList">
  516. <li class="blockList">
  517. <h4>DirectoryWalker</h4>
  518. <pre>protected&nbsp;DirectoryWalker(<a href="http://docs.oracle.com/javase/7/docs/api/java/io/FileFilter.html?is-external=true" title="class or interface in java.io">FileFilter</a>&nbsp;filter,
  519. int&nbsp;depthLimit)</pre>
  520. <div class="block">Construct an instance with a filter and limit the <i>depth</i> navigated to.
  521. <p>
  522. The filter controls which files and directories will be navigated to as
  523. part of the walk. The <a href="../../../../org/apache/commons/io/filefilter/FileFilterUtils.html" title="class in org.apache.commons.io.filefilter"><code>FileFilterUtils</code></a> class is useful for combining
  524. various filters together. A <code>null</code> filter means that no
  525. filtering should occur and all files and directories will be visited.</div>
  526. <dl>
  527. <dt><span class="paramLabel">Parameters:</span></dt>
  528. <dd><code>filter</code> - the filter to apply, null means visit all files</dd>
  529. <dd><code>depthLimit</code> - controls how <i>deep</i> the hierarchy is
  530. navigated to (less than 0 means unlimited)</dd>
  531. </dl>
  532. </li>
  533. </ul>
  534. <a name="DirectoryWalker-org.apache.commons.io.filefilter.IOFileFilter-org.apache.commons.io.filefilter.IOFileFilter-int-">
  535. <!-- -->
  536. </a>
  537. <ul class="blockListLast">
  538. <li class="blockList">
  539. <h4>DirectoryWalker</h4>
  540. <pre>protected&nbsp;DirectoryWalker(<a href="../../../../org/apache/commons/io/filefilter/IOFileFilter.html" title="interface in org.apache.commons.io.filefilter">IOFileFilter</a>&nbsp;directoryFilter,
  541. <a href="../../../../org/apache/commons/io/filefilter/IOFileFilter.html" title="interface in org.apache.commons.io.filefilter">IOFileFilter</a>&nbsp;fileFilter,
  542. int&nbsp;depthLimit)</pre>
  543. <div class="block">Construct an instance with a directory and a file filter and an optional
  544. limit on the <i>depth</i> navigated to.
  545. <p>
  546. The filters control which files and directories will be navigated to as part
  547. of the walk. This constructor uses <a href="../../../../org/apache/commons/io/filefilter/FileFilterUtils.html#makeDirectoryOnly-org.apache.commons.io.filefilter.IOFileFilter-"><code>FileFilterUtils.makeDirectoryOnly(IOFileFilter)</code></a>
  548. and <a href="../../../../org/apache/commons/io/filefilter/FileFilterUtils.html#makeFileOnly-org.apache.commons.io.filefilter.IOFileFilter-"><code>FileFilterUtils.makeFileOnly(IOFileFilter)</code></a> internally to combine the filters.
  549. A <code>null</code> filter means that no filtering should occur.</div>
  550. <dl>
  551. <dt><span class="paramLabel">Parameters:</span></dt>
  552. <dd><code>directoryFilter</code> - the filter to apply to directories, null means visit all directories</dd>
  553. <dd><code>fileFilter</code> - the filter to apply to files, null means visit all files</dd>
  554. <dd><code>depthLimit</code> - controls how <i>deep</i> the hierarchy is
  555. navigated to (less than 0 means unlimited)</dd>
  556. </dl>
  557. </li>
  558. </ul>
  559. </li>
  560. </ul>
  561. <!-- ============ METHOD DETAIL ========== -->
  562. <ul class="blockList">
  563. <li class="blockList"><a name="method.detail">
  564. <!-- -->
  565. </a>
  566. <h3>Method Detail</h3>
  567. <a name="walk-java.io.File-java.util.Collection-">
  568. <!-- -->
  569. </a>
  570. <ul class="blockList">
  571. <li class="blockList">
  572. <h4>walk</h4>
  573. <pre>protected final&nbsp;void&nbsp;walk(<a href="http://docs.oracle.com/javase/7/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</a>&nbsp;startDirectory,
  574. <a href="http://docs.oracle.com/javase/7/docs/api/java/util/Collection.html?is-external=true" title="class or interface in java.util">Collection</a>&lt;<a href="../../../../org/apache/commons/io/DirectoryWalker.html" title="type parameter in DirectoryWalker">T</a>&gt;&nbsp;results)
  575. throws <a href="http://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></pre>
  576. <div class="block">Internal method that walks the directory hierarchy in a depth-first manner.
  577. <p>
  578. Users of this class do not need to call this method. This method will
  579. be called automatically by another (public) method on the specific subclass.
  580. <p>
  581. Writers of subclasses should call this method to start the directory walk.
  582. Once called, this method will emit events as it walks the hierarchy.
  583. The event methods have the prefix <code>handle</code>.</div>
  584. <dl>
  585. <dt><span class="paramLabel">Parameters:</span></dt>
  586. <dd><code>startDirectory</code> - the directory to start from, not null</dd>
  587. <dd><code>results</code> - the collection of result objects, may be updated</dd>
  588. <dt><span class="throwsLabel">Throws:</span></dt>
  589. <dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/NullPointerException.html?is-external=true" title="class or interface in java.lang">NullPointerException</a></code> - if the start directory is null</dd>
  590. <dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></code> - if an I/O Error occurs</dd>
  591. </dl>
  592. </li>
  593. </ul>
  594. <a name="checkIfCancelled-java.io.File-int-java.util.Collection-">
  595. <!-- -->
  596. </a>
  597. <ul class="blockList">
  598. <li class="blockList">
  599. <h4>checkIfCancelled</h4>
  600. <pre>protected final&nbsp;void&nbsp;checkIfCancelled(<a href="http://docs.oracle.com/javase/7/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</a>&nbsp;file,
  601. int&nbsp;depth,
  602. <a href="http://docs.oracle.com/javase/7/docs/api/java/util/Collection.html?is-external=true" title="class or interface in java.util">Collection</a>&lt;<a href="../../../../org/apache/commons/io/DirectoryWalker.html" title="type parameter in DirectoryWalker">T</a>&gt;&nbsp;results)
  603. throws <a href="http://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></pre>
  604. <div class="block">Checks whether the walk has been cancelled by calling <a href="../../../../org/apache/commons/io/DirectoryWalker.html#handleIsCancelled-java.io.File-int-java.util.Collection-"><code>handleIsCancelled(java.io.File, int, java.util.Collection&lt;T&gt;)</code></a>,
  605. throwing a <code>CancelException</code> if it has.
  606. <p>
  607. Writers of subclasses should not normally call this method as it is called
  608. automatically by the walk of the tree. However, sometimes a single method,
  609. typically <a href="../../../../org/apache/commons/io/DirectoryWalker.html#handleFile-java.io.File-int-java.util.Collection-"><code>handleFile(java.io.File, int, java.util.Collection&lt;T&gt;)</code></a>, may take a long time to run. In that case,
  610. you may wish to check for cancellation by calling this method.</div>
  611. <dl>
  612. <dt><span class="paramLabel">Parameters:</span></dt>
  613. <dd><code>file</code> - the current file being processed</dd>
  614. <dd><code>depth</code> - the current file level (starting directory = 0)</dd>
  615. <dd><code>results</code> - the collection of result objects, may be updated</dd>
  616. <dt><span class="throwsLabel">Throws:</span></dt>
  617. <dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></code> - if an I/O Error occurs</dd>
  618. </dl>
  619. </li>
  620. </ul>
  621. <a name="handleIsCancelled-java.io.File-int-java.util.Collection-">
  622. <!-- -->
  623. </a>
  624. <ul class="blockList">
  625. <li class="blockList">
  626. <h4>handleIsCancelled</h4>
  627. <pre>protected&nbsp;boolean&nbsp;handleIsCancelled(<a href="http://docs.oracle.com/javase/7/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</a>&nbsp;file,
  628. int&nbsp;depth,
  629. <a href="http://docs.oracle.com/javase/7/docs/api/java/util/Collection.html?is-external=true" title="class or interface in java.util">Collection</a>&lt;<a href="../../../../org/apache/commons/io/DirectoryWalker.html" title="type parameter in DirectoryWalker">T</a>&gt;&nbsp;results)
  630. throws <a href="http://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></pre>
  631. <div class="block">Overridable callback method invoked to determine if the entire walk
  632. operation should be immediately cancelled.
  633. <p>
  634. This method should be implemented by those subclasses that want to
  635. provide a public <code>cancel()</code> method available from another
  636. thread. The design pattern for the subclass should be as follows:
  637. <pre>
  638. public class FooDirectoryWalker extends DirectoryWalker {
  639. private volatile boolean cancelled = false;
  640. public void cancel() {
  641. cancelled = true;
  642. }
  643. private void handleIsCancelled(File file, int depth, Collection results) {
  644. return cancelled;
  645. }
  646. protected void handleCancelled(File startDirectory,
  647. Collection results, CancelException cancel) {
  648. // implement processing required when a cancellation occurs
  649. }
  650. }
  651. </pre>
  652. <p>
  653. If this method returns true, then the directory walk is immediately
  654. cancelled. The next callback method will be <a href="../../../../org/apache/commons/io/DirectoryWalker.html#handleCancelled-java.io.File-java.util.Collection-org.apache.commons.io.DirectoryWalker.CancelException-"><code>handleCancelled(java.io.File, java.util.Collection&lt;T&gt;, org.apache.commons.io.DirectoryWalker.CancelException)</code></a>.
  655. <p>
  656. This implementation returns false.</div>
  657. <dl>
  658. <dt><span class="paramLabel">Parameters:</span></dt>
  659. <dd><code>file</code> - the file or directory being processed</dd>
  660. <dd><code>depth</code> - the current directory level (starting directory = 0)</dd>
  661. <dd><code>results</code> - the collection of result objects, may be updated</dd>
  662. <dt><span class="returnLabel">Returns:</span></dt>
  663. <dd>true if the walk has been cancelled</dd>
  664. <dt><span class="throwsLabel">Throws:</span></dt>
  665. <dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></code> - if an I/O Error occurs</dd>
  666. </dl>
  667. </li>
  668. </ul>
  669. <a name="handleCancelled-java.io.File-java.util.Collection-org.apache.commons.io.DirectoryWalker.CancelException-">
  670. <!-- -->
  671. </a>
  672. <ul class="blockList">
  673. <li class="blockList">
  674. <h4>handleCancelled</h4>
  675. <pre>protected&nbsp;void&nbsp;handleCancelled(<a href="http://docs.oracle.com/javase/7/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</a>&nbsp;startDirectory,
  676. <a href="http://docs.oracle.com/javase/7/docs/api/java/util/Collection.html?is-external=true" title="class or interface in java.util">Collection</a>&lt;<a href="../../../../org/apache/commons/io/DirectoryWalker.html" title="type parameter in DirectoryWalker">T</a>&gt;&nbsp;results,
  677. <a href="../../../../org/apache/commons/io/DirectoryWalker.CancelException.html" title="class in org.apache.commons.io">DirectoryWalker.CancelException</a>&nbsp;cancel)
  678. throws <a href="http://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></pre>
  679. <div class="block">Overridable callback method invoked when the operation is cancelled.
  680. The file being processed when the cancellation occurred can be
  681. obtained from the exception.
  682. <p>
  683. This implementation just re-throws the <a href="../../../../org/apache/commons/io/DirectoryWalker.CancelException.html" title="class in org.apache.commons.io"><code>DirectoryWalker.CancelException</code></a>.</div>
  684. <dl>
  685. <dt><span class="paramLabel">Parameters:</span></dt>
  686. <dd><code>startDirectory</code> - the directory that the walk started from</dd>
  687. <dd><code>results</code> - the collection of result objects, may be updated</dd>
  688. <dd><code>cancel</code> - the exception throw to cancel further processing
  689. containing details at the point of cancellation.</dd>
  690. <dt><span class="throwsLabel">Throws:</span></dt>
  691. <dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></code> - if an I/O Error occurs</dd>
  692. </dl>
  693. </li>
  694. </ul>
  695. <a name="handleStart-java.io.File-java.util.Collection-">
  696. <!-- -->
  697. </a>
  698. <ul class="blockList">
  699. <li class="blockList">
  700. <h4>handleStart</h4>
  701. <pre>protected&nbsp;void&nbsp;handleStart(<a href="http://docs.oracle.com/javase/7/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</a>&nbsp;startDirectory,
  702. <a href="http://docs.oracle.com/javase/7/docs/api/java/util/Collection.html?is-external=true" title="class or interface in java.util">Collection</a>&lt;<a href="../../../../org/apache/commons/io/DirectoryWalker.html" title="type parameter in DirectoryWalker">T</a>&gt;&nbsp;results)
  703. throws <a href="http://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></pre>
  704. <div class="block">Overridable callback method invoked at the start of processing.
  705. <p>
  706. This implementation does nothing.</div>
  707. <dl>
  708. <dt><span class="paramLabel">Parameters:</span></dt>
  709. <dd><code>startDirectory</code> - the directory to start from</dd>
  710. <dd><code>results</code> - the collection of result objects, may be updated</dd>
  711. <dt><span class="throwsLabel">Throws:</span></dt>
  712. <dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></code> - if an I/O Error occurs</dd>
  713. </dl>
  714. </li>
  715. </ul>
  716. <a name="handleDirectory-java.io.File-int-java.util.Collection-">
  717. <!-- -->
  718. </a>
  719. <ul class="blockList">
  720. <li class="blockList">
  721. <h4>handleDirectory</h4>
  722. <pre>protected&nbsp;boolean&nbsp;handleDirectory(<a href="http://docs.oracle.com/javase/7/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</a>&nbsp;directory,
  723. int&nbsp;depth,
  724. <a href="http://docs.oracle.com/javase/7/docs/api/java/util/Collection.html?is-external=true" title="class or interface in java.util">Collection</a>&lt;<a href="../../../../org/apache/commons/io/DirectoryWalker.html" title="type parameter in DirectoryWalker">T</a>&gt;&nbsp;results)
  725. throws <a href="http://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></pre>
  726. <div class="block">Overridable callback method invoked to determine if a directory should be processed.
  727. <p>
  728. This method returns a boolean to indicate if the directory should be examined or not.
  729. If you return false, the entire directory and any subdirectories will be skipped.
  730. Note that this functionality is in addition to the filtering by file filter.
  731. <p>
  732. This implementation does nothing and returns true.</div>
  733. <dl>
  734. <dt><span class="paramLabel">Parameters:</span></dt>
  735. <dd><code>directory</code> - the current directory being processed</dd>
  736. <dd><code>depth</code> - the current directory level (starting directory = 0)</dd>
  737. <dd><code>results</code> - the collection of result objects, may be updated</dd>
  738. <dt><span class="returnLabel">Returns:</span></dt>
  739. <dd>true to process this directory, false to skip this directory</dd>
  740. <dt><span class="throwsLabel">Throws:</span></dt>
  741. <dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></code> - if an I/O Error occurs</dd>
  742. </dl>
  743. </li>
  744. </ul>
  745. <a name="handleDirectoryStart-java.io.File-int-java.util.Collection-">
  746. <!-- -->
  747. </a>
  748. <ul class="blockList">
  749. <li class="blockList">
  750. <h4>handleDirectoryStart</h4>
  751. <pre>protected&nbsp;void&nbsp;handleDirectoryStart(<a href="http://docs.oracle.com/javase/7/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</a>&nbsp;directory,
  752. int&nbsp;depth,
  753. <a href="http://docs.oracle.com/javase/7/docs/api/java/util/Collection.html?is-external=true" title="class or interface in java.util">Collection</a>&lt;<a href="../../../../org/apache/commons/io/DirectoryWalker.html" title="type parameter in DirectoryWalker">T</a>&gt;&nbsp;results)
  754. throws <a href="http://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></pre>
  755. <div class="block">Overridable callback method invoked at the start of processing each directory.
  756. <p>
  757. This implementation does nothing.</div>
  758. <dl>
  759. <dt><span class="paramLabel">Parameters:</span></dt>
  760. <dd><code>directory</code> - the current directory being processed</dd>
  761. <dd><code>depth</code> - the current directory level (starting directory = 0)</dd>
  762. <dd><code>results</code> - the collection of result objects, may be updated</dd>
  763. <dt><span class="throwsLabel">Throws:</span></dt>
  764. <dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></code> - if an I/O Error occurs</dd>
  765. </dl>
  766. </li>
  767. </ul>
  768. <a name="filterDirectoryContents-java.io.File-int-java.io.File:A-">
  769. <!-- -->
  770. </a>
  771. <ul class="blockList">
  772. <li class="blockList">
  773. <h4>filterDirectoryContents</h4>
  774. <pre>protected&nbsp;<a href="http://docs.oracle.com/javase/7/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</a>[]&nbsp;filterDirectoryContents(<a href="http://docs.oracle.com/javase/7/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</a>&nbsp;directory,
  775. int&nbsp;depth,
  776. <a href="http://docs.oracle.com/javase/7/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</a>[]&nbsp;files)
  777. throws <a href="http://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></pre>
  778. <div class="block">Overridable callback method invoked with the contents of each directory.
  779. <p>
  780. This implementation returns the files unchanged</div>
  781. <dl>
  782. <dt><span class="paramLabel">Parameters:</span></dt>
  783. <dd><code>directory</code> - the current directory being processed</dd>
  784. <dd><code>depth</code> - the current directory level (starting directory = 0)</dd>
  785. <dd><code>files</code> - the files (possibly filtered) in the directory, may be <code>null</code></dd>
  786. <dt><span class="returnLabel">Returns:</span></dt>
  787. <dd>the filtered list of files</dd>
  788. <dt><span class="throwsLabel">Throws:</span></dt>
  789. <dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></code> - if an I/O Error occurs</dd>
  790. <dt><span class="simpleTagLabel">Since:</span></dt>
  791. <dd>2.0</dd>
  792. </dl>
  793. </li>
  794. </ul>
  795. <a name="handleFile-java.io.File-int-java.util.Collection-">
  796. <!-- -->
  797. </a>
  798. <ul class="blockList">
  799. <li class="blockList">
  800. <h4>handleFile</h4>
  801. <pre>protected&nbsp;void&nbsp;handleFile(<a href="http://docs.oracle.com/javase/7/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</a>&nbsp;file,
  802. int&nbsp;depth,
  803. <a href="http://docs.oracle.com/javase/7/docs/api/java/util/Collection.html?is-external=true" title="class or interface in java.util">Collection</a>&lt;<a href="../../../../org/apache/commons/io/DirectoryWalker.html" title="type parameter in DirectoryWalker">T</a>&gt;&nbsp;results)
  804. throws <a href="http://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></pre>
  805. <div class="block">Overridable callback method invoked for each (non-directory) file.
  806. <p>
  807. This implementation does nothing.</div>
  808. <dl>
  809. <dt><span class="paramLabel">Parameters:</span></dt>
  810. <dd><code>file</code> - the current file being processed</dd>
  811. <dd><code>depth</code> - the current directory level (starting directory = 0)</dd>
  812. <dd><code>results</code> - the collection of result objects, may be updated</dd>
  813. <dt><span class="throwsLabel">Throws:</span></dt>
  814. <dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></code> - if an I/O Error occurs</dd>
  815. </dl>
  816. </li>
  817. </ul>
  818. <a name="handleRestricted-java.io.File-int-java.util.Collection-">
  819. <!-- -->
  820. </a>
  821. <ul class="blockList">
  822. <li class="blockList">
  823. <h4>handleRestricted</h4>
  824. <pre>protected&nbsp;void&nbsp;handleRestricted(<a href="http://docs.oracle.com/javase/7/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</a>&nbsp;directory,
  825. int&nbsp;depth,
  826. <a href="http://docs.oracle.com/javase/7/docs/api/java/util/Collection.html?is-external=true" title="class or interface in java.util">Collection</a>&lt;<a href="../../../../org/apache/commons/io/DirectoryWalker.html" title="type parameter in DirectoryWalker">T</a>&gt;&nbsp;results)
  827. throws <a href="http://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></pre>
  828. <div class="block">Overridable callback method invoked for each restricted directory.
  829. <p>
  830. This implementation does nothing.</div>
  831. <dl>
  832. <dt><span class="paramLabel">Parameters:</span></dt>
  833. <dd><code>directory</code> - the restricted directory</dd>
  834. <dd><code>depth</code> - the current directory level (starting directory = 0)</dd>
  835. <dd><code>results</code> - the collection of result objects, may be updated</dd>
  836. <dt><span class="throwsLabel">Throws:</span></dt>
  837. <dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></code> - if an I/O Error occurs</dd>
  838. </dl>
  839. </li>
  840. </ul>
  841. <a name="handleDirectoryEnd-java.io.File-int-java.util.Collection-">
  842. <!-- -->
  843. </a>
  844. <ul class="blockList">
  845. <li class="blockList">
  846. <h4>handleDirectoryEnd</h4>
  847. <pre>protected&nbsp;void&nbsp;handleDirectoryEnd(<a href="http://docs.oracle.com/javase/7/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</a>&nbsp;directory,
  848. int&nbsp;depth,
  849. <a href="http://docs.oracle.com/javase/7/docs/api/java/util/Collection.html?is-external=true" title="class or interface in java.util">Collection</a>&lt;<a href="../../../../org/apache/commons/io/DirectoryWalker.html" title="type parameter in DirectoryWalker">T</a>&gt;&nbsp;results)
  850. throws <a href="http://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></pre>
  851. <div class="block">Overridable callback method invoked at the end of processing each directory.
  852. <p>
  853. This implementation does nothing.</div>
  854. <dl>
  855. <dt><span class="paramLabel">Parameters:</span></dt>
  856. <dd><code>directory</code> - the directory being processed</dd>
  857. <dd><code>depth</code> - the current directory level (starting directory = 0)</dd>
  858. <dd><code>results</code> - the collection of result objects, may be updated</dd>
  859. <dt><span class="throwsLabel">Throws:</span></dt>
  860. <dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></code> - if an I/O Error occurs</dd>
  861. </dl>
  862. </li>
  863. </ul>
  864. <a name="handleEnd-java.util.Collection-">
  865. <!-- -->
  866. </a>
  867. <ul class="blockListLast">
  868. <li class="blockList">
  869. <h4>handleEnd</h4>
  870. <pre>protected&nbsp;void&nbsp;handleEnd(<a href="http://docs.oracle.com/javase/7/docs/api/java/util/Collection.html?is-external=true" title="class or interface in java.util">Collection</a>&lt;<a href="../../../../org/apache/commons/io/DirectoryWalker.html" title="type parameter in DirectoryWalker">T</a>&gt;&nbsp;results)
  871. throws <a href="http://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></pre>
  872. <div class="block">Overridable callback method invoked at the end of processing.
  873. <p>
  874. This implementation does nothing.</div>
  875. <dl>
  876. <dt><span class="paramLabel">Parameters:</span></dt>
  877. <dd><code>results</code> - the collection of result objects, may be updated</dd>
  878. <dt><span class="throwsLabel">Throws:</span></dt>
  879. <dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></code> - if an I/O Error occurs</dd>
  880. </dl>
  881. </li>
  882. </ul>
  883. </li>
  884. </ul>
  885. </li>
  886. </ul>
  887. </div>
  888. </div>
  889. <!-- ========= END OF CLASS DATA ========= -->
  890. <!-- ======= START OF BOTTOM NAVBAR ====== -->
  891. <div class="bottomNav"><a name="navbar.bottom">
  892. <!-- -->
  893. </a>
  894. <div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
  895. <a name="navbar.bottom.firstrow">
  896. <!-- -->
  897. </a>
  898. <ul class="navList" title="Navigation">
  899. <li><a href="../../../../overview-summary.html">Overview</a></li>
  900. <li><a href="package-summary.html">Package</a></li>
  901. <li class="navBarCell1Rev">Class</li>
  902. <li><a href="class-use/DirectoryWalker.html">Use</a></li>
  903. <li><a href="package-tree.html">Tree</a></li>
  904. <li><a href="../../../../deprecated-list.html">Deprecated</a></li>
  905. <li><a href="../../../../index-all.html">Index</a></li>
  906. <li><a href="../../../../help-doc.html">Help</a></li>
  907. </ul>
  908. </div>
  909. <div class="subNav">
  910. <ul class="navList">
  911. <li><a href="../../../../org/apache/commons/io/CopyUtils.html" title="class in org.apache.commons.io"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
  912. <li><a href="../../../../org/apache/commons/io/DirectoryWalker.CancelException.html" title="class in org.apache.commons.io"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
  913. </ul>
  914. <ul class="navList">
  915. <li><a href="../../../../index.html?org/apache/commons/io/DirectoryWalker.html" target="_top">Frames</a></li>
  916. <li><a href="DirectoryWalker.html" target="_top">No&nbsp;Frames</a></li>
  917. </ul>
  918. <ul class="navList" id="allclasses_navbar_bottom">
  919. <li><a href="../../../../allclasses-noframe.html">All&nbsp;Classes</a></li>
  920. </ul>
  921. <div>
  922. <script type="text/javascript"><!--
  923. allClassesLink = document.getElementById("allclasses_navbar_bottom");
  924. if(window==top) {
  925. allClassesLink.style.display = "block";
  926. }
  927. else {
  928. allClassesLink.style.display = "none";
  929. }
  930. //-->
  931. </script>
  932. </div>
  933. <div>
  934. <ul class="subNavList">
  935. <li>Summary:&nbsp;</li>
  936. <li><a href="#nested.class.summary">Nested</a>&nbsp;|&nbsp;</li>
  937. <li>Field&nbsp;|&nbsp;</li>
  938. <li><a href="#constructor.summary">Constr</a>&nbsp;|&nbsp;</li>
  939. <li><a href="#method.summary">Method</a></li>
  940. </ul>
  941. <ul class="subNavList">
  942. <li>Detail:&nbsp;</li>
  943. <li>Field&nbsp;|&nbsp;</li>
  944. <li><a href="#constructor.detail">Constr</a>&nbsp;|&nbsp;</li>
  945. <li><a href="#method.detail">Method</a></li>
  946. </ul>
  947. </div>
  948. <a name="skip.navbar.bottom">
  949. <!-- -->
  950. </a></div>
  951. <!-- ======== END OF BOTTOM NAVBAR ======= -->
  952. <p class="legalCopy"><small>Copyright &#169; 2002&#x2013;2017 <a href="https://www.apache.org/">The Apache Software Foundation</a>. All rights reserved.</small></p>
  953. </body>
  954. </html>