Upload original JAVA语言程序设计 course files (part 31)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
Files changed (50)
- .gitattributes+134
- 尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材.zipAdded+3
- 尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-bin.zipAdded+3
- 尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src.zipAdded+3
- 尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/LICENSE.txtAdded+203
- 尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/NOTICE.txtAdded+5
- 尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/PROPOSAL.htmlAdded+78
- 尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/RELEASE-NOTES.txtAdded+993
- 尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/build.xmlAdded+355
- 尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/checkstyle.xmlAdded+51
- 尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/findbugs-exclude-filter.xmlAdded+95
- 尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/pom.xmlAdded+422
- 尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/assembly/bin.xmlAdded+49
- 尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/assembly/src.xmlAdded+41
- 尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/changes/changes.xmlAdded+488
- 尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/changes/release-notes.vmAdded+1029
- 尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/ByteOrderMark.javaAdded+191
- 尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/Charsets.javaAdded+192
- 尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/CopyUtils.javaAdded+392
- 尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/DirectoryWalker.javaAdded+642
- 尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/EndianUtils.javaAdded+482
- 尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/FileCleaner.javaAdded+160
- 尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/FileCleaningTracker.javaAdded+288
- 尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/FileDeleteStrategy.javaAdded+157
- 尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/FileExistsException.javaAdded+60
- 尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/FileSystemUtils.javaAdded+541
- 尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/FileUtils.javaAdded
- 尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/FilenameUtils.javaAdded+1452
- 尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/HexDump.javaAdded+163
- 尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/IOCase.javaAdded+254
- 尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/IOExceptionWithCause.javaAdded+67
- 尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/IOUtils.javaAdded
- 尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/Java7Support.javaAdded+190
- 尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/LineIterator.javaAdded+180
- 尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/TaggedIOException.javaAdded+136
- 尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/ThreadMonitor.javaAdded+134
- 尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/comparator/AbstractFileComparator.javaAdded+76
- 尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/comparator/CompositeFileComparator.javaAdded+122
- 尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/comparator/DefaultFileComparator.javaAdded+68
- 尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/comparator/DirectoryFileComparator.javaAdded+81
- 尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/comparator/ExtensionFileComparator.javaAdded+123
- 尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/comparator/LastModifiedFileComparator.javaAdded+79
- 尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/comparator/NameFileComparator.javaAdded+116
- 尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/comparator/PathFileComparator.javaAdded+117
- 尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/comparator/ReverseComparator.javaAdded+69
- 尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/comparator/SizeFileComparator.javaAdded+142
- 尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/comparator/package.htmlAdded+188
- 尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/AbstractFileFilter.javaAdded+64
- 尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/AgeFileFilter.javaAdded+159
- 尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/AndFileFilter.javaAdded+170
123version https://git-lfs.github.com/spec/v1oid sha256:c235fd2dca9067031676c053a0a02ffe365fcb7de0107c1653c927971f927e37size 4077721123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137version https://git-lfs.github.com/spec/v1oid sha256:c235fd2dca9067031676c053a0a02ffe365fcb7de0107c1653c927971f927e37size 4077721尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-bin.zip filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src.zip filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-lang-2.6-bin.zip filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-lang-2.6-src.zip filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-lang3-3.6-bin.zip filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-lang3-3.6-src.zip filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/common包.jpg filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/images/1563809289418.png filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/images/image-20220412215446368.png filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/images/image-20220412230501953.png filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/images/image-20220518095907714.png filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/images/字符集.jpg filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/images/第3阶段:Java高级应用-第15章.png filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/尚硅谷_宋红康_IO流.pptx filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第16章_网络编程/apache-tomcat-8.5.15-windows-x64.zip filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第16章_网络编程/images/20220518_101503.jpg filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第16章_网络编程/images/image-20220131125934581.png filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第16章_网络编程/images/image-20220415001614195.png filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第16章_网络编程/images/image-20220415003729013.png filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第16章_网络编程/images/image-20220415010205891.png filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第16章_网络编程/images/image-20220415011744915.png filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第16章_网络编程/images/image-20220415011844298.png filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第16章_网络编程/images/image-20220415013546074.png filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第16章_网络编程/images/image-20220503144420721.png filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第16章_网络编程/images/image-20220503144450241.png filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第16章_网络编程/images/image-20220512234904047.png filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第16章_网络编程/images/image-20220514172833216.png filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第16章_网络编程/images/image-20220514173031651.png filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第16章_网络编程/images/第3阶段:Java高级应用-第16章.png filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第16章_网络编程/尚硅谷_宋红康_Tomcat8.5快速部署.docx filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第16章_网络编程/尚硅谷_宋红康_聊天室.pptx filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第17章_反射机制/images/image-20211218091234964.png filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第17章_反射机制/images/image-20220417171411631.png filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第17章_反射机制/images/image-20220524101441695.png filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第17章_反射机制/images/image-20220524101448625.png filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第17章_反射机制/images/第3阶段:Java高级应用-反射机制.png filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第17章_反射机制/images/第3阶段:Java高级应用-第17章.png filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第18章_JDK8-17新特性/images/01-交通方式.png filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第18章_JDK8-17新特性/images/1568796248165.png filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第18章_JDK8-17新特性/images/4428b288361296048.png filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第18章_JDK8-17新特性/images/image-20220525200441935.png filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第18章_JDK8-17新特性/images/image-20220527101814203.png filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第18章_JDK8-17新特性/images/image-20220527111442115.png filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第18章_JDK8-17新特性/images/image-20220528212048244.png filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第18章_JDK8-17新特性/images/image-20220528212254705.png filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第18章_JDK8-17新特性/images/image-20220529003920290.png filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第18章_JDK8-17新特性/images/jdkxintexing.jpg filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第18章_JDK8-17新特性/images/lambda表达式.jpg filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第18章_JDK8-17新特性/images/第3阶��:Java高级应用-第18章-1670946711240.png filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第18章_JDK8-17新特性/images/第3阶段:Java高级应用-第18章.png filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材.zip filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/02_学习路线图.zip filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/03_复习与企业真题.zip filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/04_拓展练习.zip filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/05_实战项目/01-授课项目/Project1(谷粒记账软件)/Project1(谷粒记账软件).zip filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/05_实战项目/01-授课项目/Project2(拼电商客户管理系统)/Project2(拼电商客户管理系统).zip filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/05_实战项目/01-授课项目/Project3(优尚开发团队人员调度系统)/Project3(优尚开发团队人员调度系统).zip filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/05_实战项目/02-拓展项目/01-硅谷银行业务管理系统/01-硅谷银行业务管理系统.zip filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/05_实战项目/02-拓展项目/02-校园通在线考试系统/02-校园通在线考试系统.zip filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/05_实战项目/02-拓展项目/03-贪吃蛇/03-贪吃蛇.zip filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/05_实战项目/02-拓展项目/04-俄罗斯方块/04-俄罗斯方块/images/image-20220315104721073.png filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/05_实战项目/02-拓展项目/04-俄罗斯方块/04-俄罗斯方块/images/image-20220315164531501.png filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/05_实战项目/02-拓展项目/04-俄罗斯方块/04-俄罗斯方块/images/image-20220315165329674.png filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/05_实战项目/02-拓展项目/04-俄罗斯方块/04-俄罗斯方块/images/image-20220315170516971.png filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/05_实战项目/02-拓展项目/04-俄罗斯方块/04-俄罗斯方块/images/image-20220315172359303.png filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/05_实战项目/02-拓展项目/04-俄罗斯方块/04-俄罗斯方块.zip filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/05_实战项目/尚硅谷_宋红康_项目开发流程与角色.pptx filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/05_实战项目.zip filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/06_软件与资料/01-Java开发环境-JDK/jdk-17.0.2_windows-x64_bin.exe filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/06_软件与资料/01-Java开发环境-JDK/jdk-8u271-windows-x64.exe filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/06_软件与资料/01-Java开发环境-JDK/JDK其它各版本下载链接/jdk-7u7-windows-x64.exe filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/06_软件与资料/01-Java开发环境-JDK/JDK其它各版本下载链接/下载链接.docx filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/06_软件与资料/02-文本编辑器-EditPlus/editplus430_64bit.exe filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/06_软件与资料/02-文本编辑器-EditPlus/Editplus保姆级教程/Editplus保姆级教程/Java[[:space:]]jdk/jdk-8u121-windows-i586.exe filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/06_软件与资料/02-文本编辑器-EditPlus/Editplus保姆级教程/Editplus保姆级教��/java.[[:space:]]api/jdk[[:space:]]api[[:space:]]1.8_google.CHM filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/06_软件与资料/02-文本编辑器-EditPlus/Editplus保姆级教程/Editplus保姆级教程/第一步/EditPlus5.3.0.2542.7z filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/06_软件与资料/02-文本编辑器-EditPlus/Editplus保姆级教程/Editplus保姆级教程/第三步汉化/EditPlus.4.1.850.64位/EditPlus.exe filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/06_软件与资料/02-文本编辑器-EditPlus/Editplus保姆级教程/Editplus保姆级教程/第三步汉化/EditPlus.4.1.850.64位.7z filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/06_软件与资料/02-文本编辑器-EditPlus/Editplus保姆级教程/Editplus保姆级教程/第二步补丁/epp410p0917_0914_64bit.exe filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/06_软件与资料/02-文本编辑器-EditPlus/Editplus保姆级教程/Editplus保姆级教程/运行c++/x86_64-8.1.0-release-win32-seh-rt_v6-rev0.7z filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/06_软件与资料/02-文本编辑器-EditPlus/Editplus保姆级教程.zip filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/06_软件与资料/03-集成开发环境-IDEA/IDEA[[:space:]]2022.1[[:space:]]注册文档/IntelliJ[[:space:]]IDEA2022.1注册文档.docx filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/06_软件与资料/03-集成开发环境-IDEA/IDEA[[:space:]]2022.1[[:space:]]注册文档/jihuo-tool.zip filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/06_软件与资料/03-集成开发环境-IDEA/ideaIU-2022.1.2.exe filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/06_软件与资料/04-其它软件/01-学习必备-md文档工具-typora-setup-x64.exe filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/06_软件与资料/04-其它软件/02-学习必备-思维导图-XMindZEN/XMind[[:space:]]ZEN/XMind[[:space:]]ZEN/XMind-ZEN-for-Windows-32bit-10.0.0-201911180110.exe filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/06_软件与资料/04-其它软件/02-学习必备-思维导图-XMindZEN/XMind[[:space:]]ZEN/XMind[[:space:]]ZEN/XMind-ZEN-for-Windows-64bit-10.0.0-201911180033.exe filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/06_软件与资料/04-其它软件/02-学习必备-思维导图-XMindZEN/XMind[[:space:]]ZEN/XMind[[:space:]]ZEN/XMind-ZEN2020.10.0.0(x64)补丁/app.asar filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/06_软件与资料/04-其它软件/02-学习必备-思维导图-XMindZEN/XMind[[:space:]]ZEN/XMind[[:space:]]ZEN/XMind-ZEN2020.10.0.0(x86)补丁/app.asar filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/06_软件与资料/04-其它软件/02-学习必备-思维导图-XMindZEN.zip filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/06_软件与资料/04-其它软件/03-有道词典-YoudaoDictSetup.exe filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/06_软件与资料/04-其它软件/04-截图工具:QQScreenShotV2.5.zip filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/06_软件与资料/04-其它软件/04-截屏工具-Snipaste-2.7.3.zip filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/06_软件与资料/04-其它软件/05-反编译软件-jd-gui.exe filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/06_软件与资料/04-其它软件/06-文件对比工具-Beyond[[:space:]]Compare.zip filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/06_软件与资料/04-其它软件/07-金山打字通2.1.0.31.exe filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/06_软件与资料/04-其它软件/08-解压软件360zip_3.2.0.2220.exe filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/06_软件与资料/04-其它软件/09-360健康精灵(护眼卫士).rar filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/06_软件与资料/04-其它软件/10-Yuque-1.6.3.exe filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/06_软件与资料/04-其它软件/10-为知笔记-0.1.85-win-x64.exe filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/06_软件与资料/04-其它软件/先看说明再安装.docx filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/06_软件与资料/05-资料/API文档/Java[[:space:]]Platform[[:space:]]SE[[:space:]]8.chm filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/06_软件与资料/05-资料/API文档/jdk-17.0.2_doc-all.zip filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/06_软件与资料/05-资料/API文档/JDK_API_1.6_zh_中文.CHM filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/06_软件与资料/05-资料/API文档/JDK_API_1.6_zh_中文.chw filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/06_软件与资料/05-资料/Java基础全程单词/补充:《计算机英语词汇表》(高清晰pdf版).pdf filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/06_软件与资料/05-资料/Java基础全程单词/补充:中国程序员容易发音错误的单词.doc filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/06_软件与资料/05-资料/junit-libs/junit-4.12.jar filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/06_软件与资料/05-资料/阿里巴巴Java开发手册-1.7.1-黄山版.pdf filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/06_软件与资料.zip filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/07_授课代码.zip filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/08_授课视频/001.Java新版视频教程简介.mp4 filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/08_授课视频/02-Java语言概述-课程目录说明.mp4 filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/08_授课视频/03-Java语言概述-Java基础全程学习路线.mp4 filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/08_授课视频/04-Java语言概述-抽丝剥茧话Java.mp4 filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/08_授课视频/05-Java语言概述-Java工程师全程学习路线.mp4 filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/08_授课视频/06-Java语言概述-计算机硬件的介绍.mp4 filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/08_授课视频/07-Java语言概述-常见的DOS命令.mp4 filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/08_授课视频/08-Java语言概述-不同编程语言的介绍.mp4 filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/08_授课视频/09-Java语言概述-Java相关历史.mp4 filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/08_授课视频/10-Java语言概述-JDK的选择和下载.mp4 filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/08_授课视频/100-面向对象(进阶)-向下转型与多态性课后练习1-4.mp4 filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/08_授课视频/101-面向对象(进阶)-Object类及clone()、finalize()的理解.mp4 filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/08_授课视频/102-面向对象(进阶)-equals()方法的使用及练习1-2.mp4 filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/08_授课视频/103-面向对象(进阶)-toString()方法的使用及练习.mp4 filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/08_授课视频/104-面向对象(进阶)-第07章复习与企业真题.mp4 filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/08_授课视频/105-面向对象(高级)-关键字static修饰属性、方法.mp4 filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/08_授课视频/106-面向对象(高级)-static的应用举例及练习1,2.mp4 filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/08_授课视频/107-面向对象(高级)-单例设计模式与main()的理解.mp4 filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/08_授课视频/108-面向对象(高级)-类的成员之四:代码块.mp4 filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/08_授课视频/109-面向对象(高级)-小结:类中属性赋值的位置及过程.mp4 filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/08_授课视频/11-Java语言概述-JDK8的安装与path环境变量的配置.mp4 filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/08_授课视频/110-面向对象(高级)-关键字final的使用及真题.mp4 filter=lfs diff=lfs merge=lfs -text尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/08_授课视频/111-面向对象(高级)-抽象类与抽象方法的使用.mp4 filter=lfs diff=lfs merge=lfs -text
123version https://git-lfs.github.com/spec/v1oid sha256:b618acd0a2be7fa7b0847b10de6d15aa0bc6a77bebfbd52a8ffcc4cec3b65bc6size 431855233123version https://git-lfs.github.com/spec/v1oid sha256:be9c78df26d2997bf4ab5b0f2ea7fcf80c265fba9d962e7f20255e8a811fead0size 1686431123version https://git-lfs.github.com/spec/v1oid sha256:d44c461dc110e1bf6e8a5e74c38101544d41c6b6e379308e5420521271bcf279size 638391123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
12345Apache Commons IOCopyright 2002-2016 The Apache Software Foundation
This product includes software developed atThe Apache Software Foundation (http://www.apache.org/).123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.--><html><head> <title>Proposal for IO Package</title></head> <body bgcolor="white"> <div align="center"> <h1>Proposal for <em>IO</em> Package</h1> </div> <h3>(0) Rationale</h3> <p>Many software projects have a need to perform I/O in various ways, andthe JDK class libraries provide a lot of functionality, but sometimes youneed just a little bit more. The io package seeks to encapsulate some ofthe most popular i/o base classes into one easy to use package.</p> <h3>(1) Scope of the Package</h3> <p>This proposal is to create a package of Java utility classes for varioustypes of i/o related activity.</p> <h3>(1.5) Interaction With Other Packages</h3> <p><em>IO</em> relies only on standard JDK 1.2 (or later) APIs for productiondeployment. It utilizes the JUnit unit testing framework for developingand executing unit tests, but this is of interest only to developers of thecomponent. IO will be a dependency for several existing components in theopen source world.</p> <p>No external configuration files are utilized.</p> <h3>(2) Initial Source of the Package</h3> <p>The original Java classes are splashed around various Apache subprojects. We intend to seek them out and integrate them.</p> <p>The proposed package name for the new component is <code>org.apache.commons.io</code>.</p> <h3>(3) Required Jakarta-Commons Resources</h3> <ul> <li>CVS Repository - New directory <code>io</code> in the <code>jakarta-commons</code>CVS repository.</li> <li>Mailing List - Discussions will take place on the general <em>dev@commons.apache.org</em>mailing list. To help list subscribers identify messages of interest,it is suggested that the message subject of messages about this componentbe prefixed with [IO].</li> <li>Bugzilla - New component "IO" under the "Commons" product category,with appropriate version identifiers as needed.</li> <li>Jyve FAQ - New category "commons-io" (when available).</li> </ul> <h3>(4) Initial Committers</h3> <p>The initial committers on the IO component shall be Scott Sanders andNicola Ken Barozzi and Henri Yandell</p> <br></body></html>123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993
Apache Commons IO Version 2.5Release Notes
INTRODUCTION:
Commons IO is a package of Java utility classes like java.io. Classes in this package are considered to be so standard and of such high reuse as to justify existence in java.io.
The Apache Commons IO library contains utility classes, stream implementations, file filters, file comparators, endian transformation classes, and much more.
==============================================================================Apache Commons IO Version 2.5==============================================================================New features and bug fixes.
Changes in this version include:
New features:o IO-487: Add ValidatingObjectInputStream for controlled deserialization o IO-471: Support for additional encodings in ReversedLinesFileReader Thanks to Leandro Reis. o IO-425: Setter method for threshold on ThresholdingOutputStream Thanks to Craig Swank. o IO-406: Introduce new class AppendableOutputStream Thanks to Niall Pemberton. o IO-459: Add WindowsLineEndingInputStream and UnixLineEndingInputStream. Thanks to Kristian Rosenvold. o IO-457: Add a BoundedReader, a wrapper that can be used to constrain access to an underlying stream when used with mark/reset - to avoid overflowing the mark limit of the underlying buffer. Thanks to Kristian Rosenvold. o IO-426: Add API IOUtils.closeQuietly(Closeable...) o IO-410: Readfully() That Returns A Byte Array Thanks to Beluga Behr. o IO-395: Overload IOUtils buffer methods to accept buffer size Thanks to Beluga Behr. o IO-382: Chunked IO for large arrays. Added writeChunked(byte[], OutputStream) and writeChunked(char[] Writer) Added ChunkedOutputStream, ChunkedWriter o IO-233: Add Methods for Buffering Streams/Writers To IOUtils Added overloaded buffer() methods - see also IO-330 o IO-330: IOUtils#toBufferedOutputStream/toBufferedWriter to conditionally wrap the output Added overloaded buffer() methods - see also IO-233 o IO-381: Add FileUtils.copyInputStreamToFile API with option to leave the source open. See copyInputStreamToFile(final InputStream source, final File destination, boolean closeSource) o IO-379: CharSequenceInputStream - add tests for available() Fix code so it really does reflect a minimum available. o IO-346: Add ByteArrayOutputStream.toInputStream() o IO-341: A constant for holding the BOM character (U+FEFF) o IO-361: Add API FileUtils.forceMkdirsParent(). o IO-360: Add API Charsets.requiredCharsets(). o IO-359: Add IOUtils.skip and skipFully(ReadableByteChannel, long). Thanks to yukoba. o IO-358: Add IOUtils.read and readFully(ReadableByteChannel, ByteBuffer buffer). Thanks to yukoba. o IO-353: Add API IOUtils.copy(InputStream, OutputStream, int) Thanks to ggregory. o IO-349: Add API with array offset and length argument to FileUtils.writeByteArrayToFile. Thanks to scop. o IO-348: Missing information in IllegalArgumentException thrown by org.apache.commons.io.FileUtils#validateListFilesParameters. Thanks to plcstpierre. o IO-345: Supply a hook method allowing Tailer actively determining stop condition. Thanks to mkresse. o IO-437: Make IOUtils.EOF public and reuse it in various classes.
Fixed Bugs:o IO-446: adds an endOfFileReached method to the TailerListener Thanks to Jeffrey Barrus. o IO-484: FilenameUtils should handle embedded null bytes Thanks to Philippe Arteau. o IO-481: Changed/Corrected algorithm for waitFor o IO-428: BOMInputStream.skip returns wrong count if stream contains no BOM Thanks to Stefan Gmeiner. o IO-488: FileUtils.waitFor(...) swallows thread interrupted status Thanks to Bj�rn Buchner. o IO-452: Support for symlinks with missing target. Added support for JDK7 symlink features when present Thanks to David Standish. o IO-453: Regression in FileUtils.readFileToString from 2.0.1 Thanks to Steven Christou. o IO-451: ant test fails - resources missing from test classpath Thanks to David Standish. o IO-435: Document that FileUtils.deleteDirectory, directoryContains and cleanDirectory may throw an IllegalArgumentException in case the passed directory does not exist or is not a directory. Thanks to Dominik Stadler. o IO-424: Javadoc fixes, mostly to appease 1.8.0 Thanks to Ville Skytt�. o IO-389: FileUtils.sizeOfDirectory can throw IllegalArgumentException Thanks to Austin Doupnik. o IO-390: FileUtils.sizeOfDirectoryAsBigInteger can overflow. Ensure that recursive calls all use BigInteger o IO-385: FileUtils.doCopyFile can potentially loop for ever Exit loop if no data to copy o IO-383: FileUtils.doCopyFile caches the file size; needs to be documented Added Javadoc; show file lengths in exception message o IO-380: FileUtils.copyInputStreamToFile should document it closes the input source Thanks to claudio_ch. o IO-279: Tailer erroneously considers file as new. Fix to use file.lastModified() rather than System.currentTimeMillis() o IO-356: CharSequenceInputStream#reset() behaves incorrectly in case when buffer size is not dividable by data size. Fix code so skip relates to the encoded bytes; reset now re-encodes the data up to the point of the mark o IO-368: ClassLoaderObjectInputStream does not handle primitive typed members o IO-314: Deprecate all methods that use the default encoding o IO-338: When a file is rotated, finish reading previous file prior to starting new one o IO-354: Commons IO Tailer does not respect UTF-8 Charset. o IO-323: What should happen in FileUtils.sizeOf[Directory] when an overflow takes place? Added Javadoc. o IO-372: FileUtils.moveDirectory can produce misleading error message on failiure o IO-362: IOUtils.contentEquals* methods returns false if input1 == input2, should return true. Thanks to mmadson, ggregory. o IO-357: [Tailer] InterruptedException while the thread is sleeping is silently ignored Thanks to mortenh. o IO-352: Spelling fixes. Thanks to scop. o IO-436: Improper JavaDoc comment for FilenameUtils.indexOfExtension. Thanks to christoph.schneegans.
Changes:o IO-433: Converted all testcases to JUnit 4 o IO-466: Added testcase to show this was fixed with IO-423 o IO-479: Correct exception message in FileUtils.getFile(File, String...) Thanks to Zhouce Chen. o IO-465: Update to JUnit 4.12 Thanks to based2. o IO-462: IOExceptionWithCause no longer needed o IO-422: Deprecate Charsets Charset constants in favor of Java 7's java.nio.charset.StandardCharsets o IO-239: Convert IOCase to a Java 1.5+ Enumeration [N.B. this is binary compatible] o IO-328: getPrefixLength returns null if filename has leading slashes Javadoc: add examples to show correct behaviour; add unit tests o IO-299: FileUtils.listFilesAndDirs includes original dir in results even when it doesn't match filter Javadoc: clarify that original dir is included in the results o IO-375: FilenameUtils.splitOnTokens(String text) check for '**' could be simplified o IO-374: WildcardFileFilter ctors should not use null to mean IOCase.SENSITIVE when delegating to other ctors
Compatibility with 2.4:Binary compatible: Yes.Source compatible: Yes.Semantic compatible: Yes.
Compatibility with 2.2 and 1.4:Binary compatible: Yes.Source compatible: No, see the rare case in https://issues.apache.org/jira/browse/IO-318.Semantic compatible: No, see the rare case in https://issues.apache.org/jira/browse/IO-318.
Commons IO 2.5 requires JDK 1.6 or later.Commons IO 2.4 requires JDK 1.6 or later.Commons IO 2.3 requires JDK 1.6 or later.Commons IO 2.2 requires JDK 1.5 or later.Commons IO 1.4 requires JDK 1.3 or later.
==============================================================================Apache Commons IO Version 2.4==============================================================================
Changes in this version include:
New features:o IO-269: Tailer locks file from deletion/rename on Windows. Thanks tosebb.o IO-333: Export OSGi packages at version 1.x in addition to 2.x. Thanksto fmeschbe.o IO-320: Add XmlStreamReader support for UTF-32. Thanks to ggregory.o IO-331: BOMInputStream wrongly detects UTF-32LE_BOM files asUTF-16LE_BOM files in method getBOM(). Thanks to ggregory.o IO-327: Add byteCountToDisplaySize(BigInteger). Thanks to ggregory.o IO-326: Add new FileUtils.sizeOf[Directory] APIs to return BigInteger.Thanks to ggregory.o IO-325: Add IOUtils.toByteArray methods to work with URL and URI. Thanksto raviprak.o IO-324: Add missing Charset sister APIs to method that take a Stringcharset name. Thanks to raviprak.
Fixed Bugs:o IO-336: Yottabyte (YB) incorrectly defined in FileUtils. Thanks torleavelle.o IO-279: Tailer erroneously considers file as new. Thanks to SergioBossa, Chris Baron.o IO-335: Tailer#readLines - incorrect CR handling.o IO-334: FileUtils.toURLs throws NPE for null parameter; document thebehavior.o IO-332: Improve tailer's reading performance. Thanks to liangly.o IO-279: Improve Tailer performance with buffered reads (see IO-332).o IO-329: FileUtils.writeLines uses unbuffered IO. Thanks to tivv.o IO-319: FileUtils.sizeOfDirectory follows symbolic links. Thanks toraviprak.
Compatibility with 2.3:Binary compatible: Yes.Source compatible: Yes.Semantic compatible: Yes.
Compatibility with 2.2 and 1.4:Binary compatible: Yes.Source compatible: No, see the rare case in https://issues.apache.org/jira/browse/IO-318.Semantic compatible: No, see the rare case in https://issues.apache.org/jira/browse/IO-318.
Commons IO 2.4 requires JDK 1.6 or later.Commons IO 2.3 requires JDK 1.6 or later.Commons IO 2.2 requires JDK 1.5 or later.Commons IO 1.4 requires JDK 1.3 or later.
==============================================================================Apache Commons IO Version 2.3==============================================================================
Changes in this version include:
New features:o IO-322: Add and use class Charsets. Thanks to ggregory. o IO-321: ByteOrderMark UTF_32LE is incorrect. Thanks to ggregory. o IO-318: Add Charset sister APIs to method that take a String charset name. Thanks to ggregory.
Compatibility with 2.2 and 1.4:Binary compatible: Yes.Source compatible: No, see the rare case in https://issues.apache.org/jira/browse/IO-318.Semantic compatible: No, see the rare case in https://issues.apache.org/jira/browse/IO-318.
Commons IO 2.3 requires JDK 1.6 or later.Commons IO 2.2 requires JDK 1.5 or later.Commons IO 1.4 requires JDK 1.3 or later.
==============================================================================Apache Commons IO Version 2.2==============================================================================
Changes in this version include:
New features:o Add IOUTils.toBufferedReader(Reader) Issue: IO-313. Thanks to ggregory. o Allow applications to provide buffer (or size) for copyLarge methods. Issue: IO-308. Thanks to Manoj Mokashi. o New copyLarge() method in IOUtils that takes additional offset, length arguments Issue: IO-305. Thanks to Manoj Mokashi. o Use terabyte (TB), petabyte (PB) and exabyte (EB) in FileUtils.byteCountToDisplaySize(long size) Issue: IO-287. Thanks to Ron Kuris, Gary Gregory. o FileUtils.listFiles() doesn't return directories Issue: IO-173. Thanks to Marcos Vin�cius da Silva. o CharSequenceInputStream to efficiently stream content of a CharSequence Issue: IO-297. Thanks to Oleg Kalnichevski. o The second constructor of Tailer class does not pass 'delay' to the third one Issue: IO-304. Thanks to liangly. o TeeOutputStream does not call branch.close() when main.close() throws an exception Issue: IO-303. Thanks to fabian.barney. o ArrayIndexOutOfBoundsException in BOMInputStream when reading a file without BOM multiple times Issue: IO-302. Thanks to jsteuerwald, detinho. o Add IOUtils.closeQuietly(Selector) necessary Issue: IO-301. Thanks to kaykay.unique. o IOUtils.closeQuietly() should take a ServerSocket as a parameter Issue: IO-292. Thanks to sebb. o Add read/readFully methods to IOUtils Issue: IO-290. Thanks to sebb. o Supply a ReversedLinesFileReader Issue: IO-288. Thanks to Georg Henzler. o Add new function FileUtils.directoryContains. Issue: IO-291. Thanks to ggregory. o FileUtils.contentEquals and IOUtils.contentEquals - Add option to ignore "line endings" Added contentEqualsIgnoreEOL methods to both classes Issue: IO-275. Thanks to CJ Aspromgos.
Fixed Bugs:o IOUtils.read(InputStream/Reader) ignores the offset parameter Issue: IO-311. Thanks to Robert Muir. o CharSequenceInputStream(CharSequence s, Charset charset, int bufferSize) ignores bufferSize Issue: IO-312. o FileUtils.moveDirectoryToDirectory removes source directory if destination is a subdirectory Issue: IO-300. o ReaderInputStream#read(byte[] b, int off, int len) should check for valid parameters Issue: IO-307. o ReaderInputStream#read(byte[] b, int off, int len) should always return 0 for length == 0 Issue: IO-306. o "FileUtils#deleteDirectoryOnExit(File)" does not work Issue: IO-276. Thanks to nkami. o BoundedInputStream.read() treats max differently from BoundedInputStream.read(byte[]...) Issue: IO-273. Thanks to sebb. o Various methods of class 'org.apache.commons.io.FileUtils' incorrectly suppress 'java.io.IOException' Issue: IO-298. Thanks to Christian Schulte.
Changes:o ReaderInputStream optimization: more efficient reading of small chunks of data Issue: IO-296. Thanks to Oleg Kalnichevski.
Compatibility with 2.1 and 1.4:Binary compatible: YesSource compatible: YesSemantic compatible: Yes. Check the bug fixes section for semantic bug fixes
Commons IO 2.2 requires a minimum of JDK 1.5. Commons IO 1.4 requires a minimum of JDK 1.3.
==============================================================================Apache Commons IO Version 2.1==============================================================================
New features:o Use standard Maven directory layout Issue: IO-285. Thanks to ggregory. o Add IOUtils API toString for URL and URI to get contents Issue: IO-284. Thanks to ggregory. o Add API FileUtils.copyFile(File input, OutputStream output) Issue: IO-282. Thanks to ggregory. o FileAlterationObserver has no getter for FileFilter Issue: IO-262. o Add FileUtils.getFile API with varargs parameter Issue: IO-261. o Add new APPEND parameter for writing string into files Issue: IO-182. o Add new read method "toByteArray" to handle InputStream with known size. Issue: IO-251. Thanks to Marco Albini.
Fixed Bugs:o Dubious use of mkdirs() return code Issue: IO-280. Thanks to sebb. o ReaderInputStream enters infinite loop when it encounters an unmappable character Issue: IO-277. o FileUtils.moveFile() JavaDoc should specify FileExistsException thrown Issue: IO-264. o ClassLoaderObjectInputStream does not handle Proxy classes Issue: IO-260. o Tailer returning partial lines when reaching EOF before EOL Issue: IO-274. Thanks to Frank Grimes. o FileUtils.copyFile() throws IOException when copying large files to a shared directory (on Windows) Issue: IO-266. Thanks to Igor Smereka. o FileSystemUtils.freeSpaceKb throws exception for Windows volumes with no visible files. Improve coverage by also looking for hidden files. Issue: IO-263. Thanks to Gil Adam.
Changes:o FileAlterationMonitor.stop(boolean allowIntervalToFinish) Issue: IO-259.
==============================================================================Apache Commons IO Package 2.0.1==============================================================================
Compatibility with 2.0 and 1.4------------------------------Binary compatible - Yes
Source compatible - Yes
Semantic compatible - Yes Check the bug fixes section for semantic bug fixes
Commons IO 2.0.1 requires a minimum of JDK 1.5 (Commons IO 1.4 had a minimum of JDK 1.3)
Enhancements from 2.0---------------------
* [IO-256] - Provide thread factory for FileAlternationMonitor
Bug fixes from 2.0------------------
* [IO-257] - BOMInputStream.read(byte[]) can return 0 which it should not * [IO-258] - XmlStreamReader consumes the stream during encoding detection
==============================================================================Apache Commons IO Package 2.0==============================================================================
Compatibility with 1.4----------------------Binary compatible - Yes
Source compatible - Yes
Semantic compatible - Yes Check the bug fixes section for semantic bug fixes
Commons IO 2.0 requires a minimum of JDK 1.5 (Commons IO 1.4 had a minimum of JDK 1.3)
Deprecations from 1.4---------------------
- IOUtils - write(StringBuffer, Writer) in favour of write(CharSequence, Writer) - write(StringBuffer, OutputStream) in favour of write(CharSequence, OutputStream) - write(StringBuffer, OutputStream, String) in favour of write(CharSequence, OutputStream, String)
- FileFilterUtils - andFileFilter(IOFileFilter, IOFileFilter) in favour of and(IOFileFilter...) - orFileFilter(IOFileFilter, IOFileFilter) in favour of or(IOFileFilter...)
Enhancements from 1.4---------------------
* [IO-140] Move minimum Java requirement from JDK 1.3 to JDK 1.5 - use Generics - add new CharSequence write() flavour methods to IOUtils and FileUtils - replace StringBuffer with StringBuilder, where appropriate - add new Reader/Writer methods to ProxyReader and ProxyWriter - Annotate with @Override and @Deprecated
* [IO-178] New BOMInputStream and ByteOrderMark implementations - to detect and optionally exclude an initial Byte Order mark (BOM) * [IO-197] New BoundedInputStream (copied from from Apache JackRabbit) * [IO-193] New Broken Input and Output streams * [IO-132] New File Listener/Monitor facility * [IO-158] New ReaderInputStream and WriterOutputStream implementations * [IO-139] New StringBuilder Writer implementation * [IO-192] New Tagged Input and Output streams * [IO-177] New Tailer class - simple implementation of the Unix "tail -f" functionality * [IO-162] New XML Stream Reader/Writer implementations (from ROME via plexus-utils)
* [IO-142] Comparators - add facility to sort file lists/arrays * [IO-186] Comparators - new Composite and Directory File Comparator implementations * [IO-176] DirectoryWalker - add filterDirectoryContents() callback method for filtering directory contents * [IO-210] FileFilter - new Magic Number FileFilter * [IO-221] FileFilterUtils - add methods for suffix and prefix filters which take an IOCase object * [IO-232] FileFilterUtils - add method for name filters which take an IOCase object * [IO-229] FileFilterUtils - add varargs and() and or() methods * [IO-198] FileFilterUtils - add ability to apply file filters to collections and arrays * [IO-156] FilenameUtils - add normalize() and normalizeNoEndSeparator() methods which allow the separator character to be specified * [IO-194] FileSystemUtils - add freeSpaceKb() method with no input arguments * [IO-185] FileSystemUtils - add freeSpaceKb() methods that take a timeout parameter - fixes freeSpaceWindows() blocks * [IO-155] FileUtils - use NIO to copy files * [IO-168] FileUtils - add new isSymlink() method * [IO-219] FileUtils - throw FileExistsException when moving a file or directory if the destination already exists * [IO-234] FileUtils - add Methods for retrieving System User/Temp directories/paths * [IO-208] FileUtils - add timeout (connection and read) support for copyURLToFile() method * [IO-238] FileUtils - add sizeOf(File) method * [IO-181] LineIterator now implements Iterable * [IO-224] IOUtils - add closeQuietly(Closeable) and closeQuietly(Socket) methods * [IO-203] IOUtils - add skipFully() method for InputStreams * [IO-137] IOUtils and ByteArrayOutputStream - add toBufferedInputStream() method to avoid unnecessary array allocation/copy * [IO-195] Proxy streams/Reader/Writer - provide exception handling methods * [IO-211] Proxy Input/Output streams - add pre/post processing support * [IO-242] Proxy Reader/Writer - add pre/post processing support
Bug fixes from 1.4------------------ * [IO-214] ByteArrayOutputStream - fix inconsistent synchronization of fields * [IO-201] Counting Input/Output streams - fix inconsistent synchronization * [IO-159] FileCleaningTracker - fix remove() never returns null * [IO-220] FileCleaningTracker - fix Vector performs badly under load * [IO-167] FilenameUtils - fix case-insensitive string handling in FilenameUtils and FilesystemUtils * [IO-179] FilenameUtils - fix StringIndexOutOfBounds exception in getPathNoEndSeparator() * [IO-248] FilenameUtils - fix getFullPathNoEndSeparator() returns empty while path is a one level directory * [IO-246] FilenameUtils - fix wildcardMatch gives incorrect results * [IO-187] FileSystemUtils - fix freeSpaceKb() doesn't work with relative paths on Linux * [IO-160] FileSystemUtils - fix freeSpace() fails on solaris * [IO-209] FileSystemUtils - fix freeSpaceKb() fails to return correct size for a windows mount point * [IO-163] FileUtils - fix toURLs() using deprecated method of conversion to URL * [IO-168] FileUtils - fix Symbolic links followed when deleting directory * [IO-231] FileUtils - fix wrong exception message generated in isFileNewer() method * [IO-207] FileUtils - fix race condition in forceMkdir() method * [IO-217] FileUtils - fix copyDirectoryToDirectory() makes infinite loops * [IO-166] FileUtils - fix URL decoding in toFile(URL) * [IO-190] FileUtils - fix copyDirectory not preserving lastmodified date on sub-directories * [IO-240] FileFilterUtils - ensure cvsFilter and svnFilter are only created once. * [IO-175] IOUtils - fix copyFile() issues with very large files * [IO-191] Improvements from static analysis * [IO-216] LockableFileWriter - delete files quietly when an exception is thrown during initialization * [IO-243] SwappedDataInputStream - fix readBoolean is inverted * [IO-235] Tests - remove unused YellOnFlushAndCloseOutputStream from CopyUtilsTest * [IO-161] Tests - fix FileCleaningTrackerTestCase hanging
Documentation changes from 1.4------------------------------ * [IO-183 FilenameUtils.getExtension() method documentation improvements * [IO-226 FileUtils.byteCountToDisplaySize() documentation corrections * [IO-205 FileUtils.forceMkdir() documentation improvements * [IO-215 FileUtils copy file/directory improve documentation regarding preserving the last modified date * [IO-189 HexDump.dump() method documentation improvements * [IO-171 IOCase document that it assumes there are only two OSes: Windows and Unix * [IO-223 IOUtils.copy() documentation corrections * [IO-247 IOUtils.closeQuietly() improve documentation with examples * [IO-202 NotFileFilter documentation corrections * [IO-206 ProxyInputStream - fix misleading parameter names * [IO-212 ProxyInputStream.skip() documentation corrections
==============================================================================Apache Commons IO Version 1.4==============================================================================
Compatibility with 1.3.2------------------------Binary compatible - Yes
Source compatible - Yes
Semantic compatible - Yes Check the bug fixes section for semantic bug fixes
Commons IO 1.4 introduces four new implementations which depend on JDK 1.4 features(CharSequenceReader, FileWriterWithEncoding, IOExceptionWithCause and RegexFileFilter).It has been built with the JDK source and target options set to JDK 1.3 and, except forthose implementations, can be used with JDK 1.3 (see IO IO-127).
Deprecations from 1.3.2------------------------ FileCleaner deprecated in favour of FileCleaningTracker [see IO-116]
Bug fixes from 1.3.2--------------------- FileUtils - forceDelete of orphaned Softlinks does not work [IO-147] - Infinite loop on FileUtils.copyDirectory when the destination directory is within the source directory [IO-141] - Add a copyDirectory() method that makes use of FileFilter [IO-105] - Add moveDirectory() and moveFile() methods [IO-77]
- HexDump - HexDump's use of static StringBuffers isn't thread-safe [IO-136]
Enhancements from 1.3.2------------------------ FileUtils - Add a deleteQuietly method [IO-135]
- FilenameUtils - Add file name extension separator constants[IO-149]
- IOExceptionWithCause [IO-148] - Add a new IOException implementation with constructors which take a cause
- TeeInputStream [IO-129] - Add new Tee input stream implementation
- FileWriterWithEncoding [IO-153] - Add new File Writer implementation that accepts an encoding
- CharSequenceReader [IO-138] - Add new Reader implementation that handles any CharSequence (String, StringBuffer, StringBuilder or CharBuffer)
- ThesholdingOuputStream [IO-121] - Add a reset() method which sets the count of the bytes written back to zero.
- DeferredFileOutputStream [IO-130] - Add support for temporary files
- ByteArrayOutputStream - Add a new write(InputStream) method [IO-152]
- New Closed Input/Output stream implementations [IO-122] - AutoCloseInputStream - automatically closes and discards the underlying input stream - ClosedInputStream - returns -1 for any read attempts - ClosedOutputStream - throws an IOException for any write attempts - CloseShieldInputStream - prevents the underlying input stream from being closed. - CloseShieldOutputStream - prevents the underlying output stream from being closed.
- Add Singleton Constants to several stream classes [IO-143]
- PrefixFileFilter [IO-126] - Add faciltiy to specify case sensitivity on prefix matching
- SuffixFileFilter [IO-126] - Add faciltiy to specify case sensitivity on suffix matching
- RegexFileFilter [IO-74] - Add new regular expression file filter implementation
- Make IOFileFilter implementations Serializable [IO-131]
- Improve IOFileFilter toString() methods [IO-120]
- Make fields final so classes are immutable/threadsafe [IO-133] - changes to Age, Delegate, Name, Not, Prefix, Regex, Size, Suffix and Wildcard IOFileFilter implementations.
- IOCase - Add a compare method to IOCase [IO-144]
- Add a package of java.util.Comparator implementations for files [IO-145] - DefaultFileComparator - compare files using the default File.compareTo(File) method. - ExtensionFileComparator - compares files using file name extensions. - LastModifiedFileComparator - compares files using the last modified date/time. - NameFileComparator - compares files using file names. - PathFileComparator - compares files using file paths. - SizeFileComparator - compares files using file sizes. ==============================================================================Apache Commons IO Version 1.3.2==============================================================================
Compatibility with 1.3.1----------------------Binary compatible - Yes
Source compatible - Yes
Semantic compatible - Yes
Compatibility with 1.3----------------------Binary compatible - No See [IO-113]
Source compatible - No See [IO-113]
Semantic compatible - Yes
Enhancements since 1.3.1------------------------
- Created the FileCleaningTracker, basically a non-static version of the FileCleaner, which can be controlled by the user. [IO-116]- The FileCleaner is deprecated.
Bug fixes from 1.3.1--------------------
- Some tests, which are implicitly assuming a Unix-like file system, are now skipped on Windows. [IO-115]- EndianUtils - Both readSwappedUnsignedInteger(...) methods could return negative numbers due to int/long casting. [IO-117]
Bug fixes from 1.3------------------
- FileUtils - NPE in openOutputStream(File) when file has no parent in path [IO-112] - readFileToString(File) is not static [IO-113]
==============================================================================Apache Commons IO Version 1.3.1==============================================================================
Compatibility with 1.3----------------------Binary compatible - No See [IO-113]
Source compatible - No See [IO-113]
Semantic compatible - Yes
Bug fixes from 1.3------------------
- FileUtils - NPE in openOutputStream(File) when file has no parent in path [IO-112] - readFileToString(File) is not static [IO-113] ==============================================================================Apache Commons IO Version 1.3==============================================================================
Compatibility with 1.2----------------------Binary compatible - Yes
Source compatible - Yes
Semantic compatible - Yes Check the bug fixes section for semantic bug fixes
Deprecations from 1.2---------------------- WildcardFilter deprecated, replaced by WildcardFileFilter - old class only accepted files, thus had a confusing dual purpose
- FileSystemUtils.freeSpace deprecated, replaced by freeSpaceKb - freeSpace returns a result that varies by operating system and thus isn't that useful - freeSpaceKb returns much better and more consistent results - freeSpaceKb existed in v1.2, so this is a gentle cutover
Bug fixes from 1.2------------------- LineIterator now implements Iterator - It was always supposed to...
- FileSystemUtils.freeSpace/freeSpaceKb [IO-83] - These should now work on AIX and HP-UX
- FileSystemUtils.freeSpace/freeSpaceKb [IO-90] - Avoid infinite looping in Windows - Catch more errors with nice messages
- FileSystemUtils.freeSpace [IO-91] - This is now documented not to work on SunOS 5
- FileSystemUtils [IO-93] - Fixed resource leak leading to 'Too many open files' error - Previously did not destroy Process instances (as JDK Javadoc is so poor) - http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4801027
- FileUtils.touch [IO-100] - The touch method previously gave no indication when the file could not be touched successfully (such as due to access restrictions) - it now throws an IOException if the last modified date cannot be changed
- FileCleaner - This now handles the situation where an error occurs when deleting the file
- IOUtils.copy [IO-84] - Copy methods could return inaccurate byte/char count for large streams - The copy(InputStream, OutputStream) method now returns -1 if the count is greater than an int - The copy(Reader, Writer) method now throws now returns -1 if the count is greater than an int - Added a new copyLarge(InputStream, OutputStream) method that returns a long - Added a new copyLarge(Reader, Writer) method that returns a long
- CountingInputStream/CountingOutputStream [IO-84] - Methods were declared as int thus the count was innacurate for large streams - new long based methods getByteCount()/resetByteCount() added - existing methods changed to throw an exception if the count is greater than an int
- FileBasedTestCase - Fixed bug in compare content methods identified by GNU classpath
- EndianUtils.writeSwappedLong(byte[], int) [IO-101] - An int overrun in the bit shifting when it should have been a long
- EndianUtils.writeSwappedLong(InputStream) [IO-102] - The return of input.read(byte[]) was not being checked to ensure all 8 bytes were read
Enhancements from 1.2---------------------- DirectoryWalker [IO-86] - New class designed for subclassing to walk through a set of files. DirectoryWalker provides the walk of the directories, filtering of directories and files, and cancellation support. The subclass must provide the specific behaviour, such as text searching or image processing.
- IOCase - New class/enumeration for case-sensitivity control
- FilenameUtils - New methods to handle case-sensitivity - wildcardMatch - new method that has IOCase as a parameter - equals - new method that has IOCase as a parameter
- FileUtils [IO-108] - new default encoding methods for: - readFileToString(File) - readLines(File) - lineIterator(File) - writeStringToFile(File, String) - writeLines(File, Collection) - writeLines(File, Collection, String)
- FileUtils.openOutputStream [IO-107] - new method to open a FileOutputStream, creating parent directories if required- FileUtils.touch- FileUtils.copyURLToFile- FileUtils.writeStringToFile- FileUtils.writeByteArrayToFile- FileUtils.writeLines - enhanced to create parent directories if required- FileUtils.openInputStream [IO-107] - new method to open a FileInputStream, providing better error messages than the JDK
- FileUtils.isFileOlder - new methods to check if a file is older (i.e. isFileOlder()) - counterparts to the existing isFileNewer() methods.
- FileUtils.checksum, FileUtils.checksumCRC32 - new methods to create a checksum of a file
- FileUtils.copyFileToDirectory [IO-104] - new variant that optionally retains the file date
- FileDeleteStrategy- FileCleaner [IO-56,IO-70] - FileDeleteStrategy is a strategy for handling file deletion - This can be used as a calback in FileCleaner - Together these allow FileCleaner to do a forceDelete to kill directories
- FileCleaner.exitWhenFinished [IO-99] - A new method that allows the internal cleaner thread to be cleanly terminated
- WildcardFileFilter - Replacement for WildcardFilter - Accepts both files and directories - Ability to control case-sensitivity
- NameFileFilter - Ability to control case-sensitivity
- FileFileFilter - New IOFileFilter implementation - Accepts files where File.isFile() is true - In other words it filters out directories - Singleton instance provided (FILE)
- CanReadFileFilter - New IOFileFilter implementation - Accepts files where File.canRead() is true - Singleton instances provided (CAN_READ/CANNOT_READ/READ_ONLY)
- CanWriteFileFilter - New IOFileFilter implementation - Accepts files where File.canWrite() is true - Singleton instances provided (CAN_WRITE/CANNOT_WRITE)
- HiddenFileFilter - New IOFileFilter implementation - Accepts files where File.isHidden() is true - Singleton instances provided (HIDDEN/VISIBLE)
- EmptyFileFilter - New IOFileFilter implementation - Accepts files or directories that are empty - Singleton instances provided (EMPTY/NOT_EMPTY)
- TrueFileFilter/FalseFileFilter/DirectoryFileFilter - New singleton instance constants (TRUE/FALSE/DIRECTORY) - The new constants are more JDK 1.5 friendly with regards to static imports (whereas if everything uses INSTANCE, then they just clash) - The old INSTANCE constants are still present and have not been deprecated
- FileFilterUtils.sizeRangeFileFilter - new sizeRangeFileFilter(long minimumSize, long maximumSize) method which creates a filter that accepts files within the specified size range.
- FileFilterUtils.makeDirectoryOnly/makeFileOnly - two new methods that decorate a file filter to make it apply to directories only or files only
- NullWriter - New writer that acts as a sink for all data, as per /dev/null
- NullInputStream - New input stream that emulates a stream of a specified size
- NullReader - New reader that emulates a reader of a specified size
- ByteArrayOutputStream [IO-97] - Performance enhancements
==============================================================================Apache Commons IO Version 1.2==============================================================================
Compatibility with 1.1----------------------Binary compatible - Yes
Source compatible - Yes
Semantic compatible - Yes
Deprecations from 1.1---------------------
Bug fixes from 1.1------------------- FileSystemUtils.freeSpace(drive) Fix to allow Windows based command to function in French locale
- FileUtils.read* Increase certainty that files are closed in case of error
- LockableFileWriter Locking mechanism was broken and only provided limited protection [38942] File deletion and locking in case of constructor error was broken
Enhancements from 1.1---------------------- AgeFileFilter/SizeFileFilter New file filters that compares against the age and size of the file
- FileSystemUtils.freeSpaceKb(drive) New method that unifies result to be in kilobytes [38574]
- FileUtils.contentEquals(File,File) Performance improved by adding length and file location checking
- FileUtils.iterateFiles Two new method to provide direct access to iterators over files
- FileUtils.lineIterator IOUtils.lineIterator New methods to provide an iterator over the lines in a file [38083]
- FileUtils.copyDirectoryToDirectory New method to copy a directory to within another directory [36315] ==============================================================================Apache Commons IO Version 1.1==============================================================================
Incompatible changes from 1.0-----------------------------Binary compatible - Yes
Source compatible - Yes
Semantic compatible - Yes, except:- FileUtils.writeStringToFile() A null encoding previously used 'ISO-8859-1', now it uses the platform default Generally this will make no difference
- LockableFileWriter Improved validation and now create directories if necesssary
plus these bug fixes may affect you semantically:- FileUtils.touch() (Bug fix 29821) Now creates the file if it did not previously exist
- FileUtils.toFile(URL) (Bug fix 32575) Now handles escape syntax such as %20
- FileUtils.sizeOfDirectory() (Bug fix 36801) May now return a size of 0 if the directory is security restricted
Deprecations from 1.0---------------------- CopyUtils has been deprecated. Its methods have been moved to IOUtils. The new IOUtils methods handle nulls better, and have clearer names.
- IOUtils.toByteArray(String) - Use {@link String#getBytes()}- IOUtils.toString(byte[]) - Use {@link String#String(byte[])}- IOUtils.toString(byte[],String) - Use {@link String#String(byte[],String)}
Bug fixes from 1.0------------------- FileUtils - touch() [29821] Now creates the file if it did not previously exist
- FileUtils - toFile(URL) [32575] Now handles escape syntax such as %20
- FileFilterUtils - makeCVSAware(IOFileFilter) [33023] Fixed bug that caused method to be completely broken
- CountingInputStream [33336] Fixed bug that caused the count to reduce by one at the end of the stream
- CountingInputStream - skip(long) [34311] Bytes from calls to this method were not previously counted
- NullOutputStream [33481] Remove unnecessary synchronization
- AbstractFileFilter - accept(File, String) [30992] Fixed broken implementation
- FileUtils [36801] Previously threw NPE when listing files in a security restricted directory Now throw IOException with a better message
- FileUtils - writeStringToFile() Null encoding now correctly uses the platform default
Enhancements from 1.0---------------------- FilenameUtils - new class [33303,29351] A static utility class for working with filenames Seeks to ease the pain of developing on Windows and deploying on Unix
- FileSystemUtils - new class [32982,36325] A static utility class for working with file systems Provides one method at present, to get the free space on the filing system
- IOUtils - new public constants Constants for directory and line separators on Windows and Unix
- IOUtils - toByteArray(Reader,encoding) Handles encodings when reading to a byte array
- IOUtils - toCharArray(InputStream) [28979] - toCharArray(InputStream,encoding) - toCharArray(Reader) Reads a stream/reader into a charatcter array
- IOUtils - readLines(InputStream) [36214] - readLines(InputStream,encoding) - readLines(Reader) Reads a stream/reader line by line into a List of Strings
- IOUtils - toInputStream(String) [32958] - toInputStream(String,encoding) Creates an input stream that uses the string as a source of data
- IOUtils - writeLines(Collection,lineEnding,OutputStream) [36214] - writeLines(Collection,lineEnding,OutputStream,encoding) - writeLines(Collection,lineEnding,Writer) Writes a collection to a stream/writer line by line
- IOUtils - write(...) Write data to a stream/writer (moved from CopyUtils with better null handling)
- IOUtils - copy(...) Copy data between streams (moved from CopyUtils with better null handling)
- IOUtils - contentEquals(Reader,Reader) Method to compare the contents of two readers
- FileUtils - toFiles(URL[]) Converts an array of URLs to an array of Files
- FileUtils - copyDirectory() [32944] New methods to copy a directory
- FileUtils - readFileToByteArray(File) Reads an entire file into a byte array
- FileUtils - writeByteArrayToFile(File,byte[]) Writes a byte array to a file
- FileUtils - readLines(File,encoding) [36214] Reads a file line by line into a List of Strings
- FileUtils - writeLines(File,encoding,List) writeLines(File,encoding,List,lineEnding) Writes a collection to a file line by line
- FileUtils - EMPTY_FILE_ARRAY Constant for an empty array of File objects
- ConditionalFileFilter - new interface [30705] Defines the behaviour of list based filters
- AndFileFilter, OrFileFilter [30705] Now support a list of filters to and/or
- WildcardFilter [31115] New filter that can match using wildcard file names
- FileFilterUtils - makeSVNAware(IOFileFilter) New method, like makeCVSAware, that ignores Subversion source control directories
- ClassLoaderObjectInputStream An ObjectInputStream that supports a ClassLoader
- CountingInputStream,CountingOutputStream - resetCount() [28976] Adds the ability to reset the count part way through reading/writing the stream
- DeferredFileOutputStream - writeTo(OutputStream) [34173] New method to allow current contents to be written to a stream
- DeferredFileOutputStream [34142] Performance optimizations avoiding double buffering
- LockableFileWriter - encoding support [36825] Add support for character encodings to LockableFileWriter Improve the validation Create directories if necesssary
- IOUtils and EndianUtils are no longer final [28978] Allows developers to have subclasses if desired
==============================================================================Feedback==============================================================================
Open source works best when you give feedback:http://commons.apache.org/io/
Please direct all bug reports to JIRAhttp://issues.apache.org/jira/browse/IO
Or subscribe to the commons-user mailing list (prefix emails by [io])http://commons.apache.org/mail-lists.html
The Commons-IO Team123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.--><project name="Commons IO" default="jar" basedir=".">
<!-- "IO" component of the Apache Commons Subproject $Id: build.xml 1714367 2015-11-14 20:46:56Z adrianc $-->
<!-- ========== Initialize Properties ===================================== -->
<property file="project.properties"/> <!-- Project local --> <property file="build.properties"/> <!-- Component local --> <property file="${user.home}/build.properties"/> <!-- User local -->
<!-- ========== External Dependencies ===================================== -->
<!-- Repository base path --> <property name="repository" value="${user.home}/.m2/repository"/>
<!-- The directories corresponding to your necessary dependencies --> <property name="junit.version" value="4.12"/> <property name="junit.home" value="${repository}/junit/junit/${junit.version}"/> <property name="junit.jar" value="${junit.home}/junit-${junit.version}.jar"/>
<!-- ========== Component Declarations ==================================== -->
<!-- The name of this component --> <property name="component.name" value="commons-io"/>
<!-- The primary package name of this component --> <property name="component.package" value="org.apache.commons.io"/>
<!-- The title of this component --> <property name="component.title" value="Commons IO"/>
<!-- The current version number of this component --> <property name="component.version" value="2.5-SNAPSHOT"/>
<!-- The base directory for component sources --> <property name="source.home" value="src/main/java"/>
<!-- The base directory for unit test sources --> <property name="test.home" value="src/test/java"/>
<!-- The base directory for unit test resources --> <property name="test.resources.home" value="src/test/resources"/>
<!-- Download lib dir --> <property name="download.lib.dir" value="lib"/>
<!-- The base directory for compilation targets --> <property name="build.home" value="target"/>
<!-- The base directory for distribution targets --> <property name="dist.home" value="${build.home}"/>
<!-- Base file name for dist files --> <property name="final.name" value="${component.name}-${component.version}"/>
<!-- Directory where binary release files are staged --> <property name="stage.bin.dir" value="${dist.home}/stage-bin"/>
<!-- Directory where source release files are staged --> <property name="stage.src.dir" value="${dist.home}/stage-src"/>
<!-- ========== Compiler Defaults ========================================= -->
<!-- compiler source JDK version --> <property name="compile.source" value="1.6"/>
<!-- compiler target JDK version --> <property name="compile.target" value="1.6"/>
<!-- Should Java compilations set the 'debug' compiler option? --> <property name="compile.debug" value="true"/>
<!-- Should Java compilations set the 'deprecation' compiler option? --> <property name="compile.deprecation" value="false"/>
<!-- Should Java compilations set the 'optimize' compiler option? --> <property name="compile.optimize" value="true"/>
<!-- Construct compile classpath --> <path id="compile.classpath"> <pathelement location="${build.home}/classes"/> </path>
<!-- Construct compile classpath --> <path id="downloaded.lib.classpath"> <pathelement location="${download.lib.dir}/junit-${junit.version}.jar"/> <pathelement location="${download.lib.dir}/hamcrest-core-1.3.jar"/> </path>
<!-- ========== Test Execution Defaults =================================== -->
<!-- Construct unit test classpath --> <path id="test.classpath"> <pathelement location="${build.home}/classes"/> <pathelement location="${build.home}/test-classes"/> <pathelement location="${build.home}/test-resources"/> <pathelement location="${junit.jar}"/> <path refid="downloaded.lib.classpath"/> </path>
<!-- Should all tests fail if one does? --> <property name="test.failonerror" value="true"/>
<!-- The test runner to execute --> <property name="test.runner" value="junit.textui.TestRunner"/>
<!-- ========== Executable Targets ======================================== -->
<target name="clean" description="Clean build and distribution directories"> <delete dir="${build.home}"/> <delete dir="test"/> </target>
<target name="init" description="Initialize and evaluate conditionals"> <echo message="-------- ${component.title} ${component.version} --------"/> <filter token="name" value="${component.name}"/> <filter token="package" value="${component.package}"/> <filter token="version" value="${component.version}"/> <filter token="compilesource" value="${compile.source}"/> <filter token="compiletarget" value="${compile.target}"/> <tstamp/> <mkdir dir="${build.home}"/> <mkdir dir="${build.home}/classes"/> <mkdir dir="${build.home}/test-classes"/> </target>
<!-- ========== Compile Targets =========================================== -->
<target name="compile" depends="init" description="Compile">
<javac srcdir="${source.home}" destdir="${build.home}/classes" source="${compile.source}" target="${compile.target}" debug="${compile.debug}" deprecation="${compile.deprecation}" optimize="${compile.optimize}" includeantruntime="false"> <classpath refid="compile.classpath"/> </javac> </target>
<!-- ========== Unit Test Targets ========================================= -->
<target name="compile.tests" depends="compile, download-dependencies" description="Compile unit test cases dependent on JDK version">
<javac srcdir="${test.home}" destdir="${build.home}/test-classes" debug="${compile.debug}" deprecation="${compile.deprecation}" optimize="${compile.optimize}" includeantruntime="false"> <classpath refid="test.classpath"/> </javac> <copy todir="${build.home}/test-resources"> <fileset dir="${test.resources.home}"/> </copy> </target>
<target name="test" depends="compile.tests" description="Run all unit test cases"> <mkdir dir="${build.home}/ant-reports"/> <junit printsummary="true" showoutput="true" fork="yes" haltonfailure="${test.failonerror}"> <classpath refid="test.classpath"/> <formatter type="plain" usefile="true" /> <!-- If test.entry is defined, run a single test, otherwise run all valid tests --> <test name="${test.entry}" if="test.entry"/> <batchtest todir="${build.home}/ant-reports" unless="test.entry"> <fileset dir="${test.home}"> <include name="**/*Test*.java"/> <!-- Test support files --> <exclude name="**/testtools/**"/> <!-- Ant JUnit does not handle abstract classes --> <exclude name="**/*AbstractTestCase*"/> <exclude name="**/Abstract*TestCase*"/> </fileset> </batchtest> </junit> </target>
<!-- ========== Produce JavaDocs ========================================== -->
<target name="javadoc" depends="compile" description="Create component Javadoc documentation"> <mkdir dir="${build.home}/apidocs"/> <tstamp> <format property="current.year" pattern="yyyy"/> </tstamp> <javadoc sourcepath="${source.home}" destdir="${build.home}/apidocs" packagenames="org.apache.commons.*" author="true" private="true" version="true" doctitle="<h1>${component.title} ${component.version}</h1>" windowtitle="${component.title} ${component.version}" bottom="Copyright (c) 2002-${current.year} Apache Software Foundation" classpathref="compile.classpath"> <link href="http://java.sun.com/javaee/5/docs/api/"/> <link href="http://download.oracle.com/javase/1.5.0/docs/api/index.html"/> </javadoc> </target>
<!-- ========== Create Jar ================================================ -->
<target name="jar" depends="compile" description="Create jar file">
<mkdir dir="${build.home}/classes/META-INF"/> <copy file="LICENSE.txt" tofile="${build.home}/classes/META-INF/LICENSE.txt"/> <copy file="NOTICE.txt" tofile="${build.home}/classes/META-INF/NOTICE.txt"/>
<manifest file="${build.home}/MANIFEST.MF"> <attribute name="Specification-Title" value="${component.title}"/> <attribute name="Specification-Version" value="${component.version}"/> <attribute name="Specification-Vendor" value="The Apache Software Foundation"/> <attribute name="Implementation-Title" value="${component.title}"/> <attribute name="Implementation-Version" value="${component.version}"/> <attribute name="Implementation-Vendor" value="The Apache Software Foundation"/> <attribute name="Implementation-Vendor-Id" value="org.apache"/> <attribute name="X-Compile-Source-JDK" value="${compile.source}"/> <attribute name="X-Compile-Target-JDK" value="${compile.target}"/> </manifest>
<jar jarfile="${build.home}/${final.name}.jar" basedir="${build.home}/classes" manifest="${build.home}/MANIFEST.MF"/> </target>
<!-- ========== Distribution Target =========================================== -->
<target name="dist" depends="clean,jar,javadoc" description="Create distribution artifacts">
<mkdir dir="${dist.home}"/>
<!-- jar(s) --> <copy todir="${dist.home}"> <fileset dir="."> <include name="RELEASE-NOTES.txt"/> </fileset> <fileset dir="${build.home}"> <include name="*.jar"/> </fileset> </copy>
<!-- Binary Distro --> <mkdir dir="${stage.bin.dir}/${final.name}"/> <copy todir="${stage.bin.dir}/${final.name}"> <fileset dir="."> <include name="LICENSE.txt"/> <include name="NOTICE.txt"/> <include name="RELEASE-NOTES.txt"/> </fileset> <fileset dir="${build.home}"> <include name="*.jar"/> </fileset> </copy> <copy todir="${stage.bin.dir}/${final.name}/apidocs"> <fileset dir="${build.home}/apidocs" /> </copy>
<!-- Source Distro --> <mkdir dir="${stage.src.dir}/${final.name}-src"/> <copy todir="${stage.src.dir}/${final.name}-src"> <fileset dir="."> <include name="build.xml"/> <include name="checkstyle.xml"/> <include name="LICENSE.txt"/> <include name="NOTICE.txt"/> <include name="pom.xml"/> <include name="PROPOSAL.html"/> <include name="RELEASE-NOTES.txt"/> </fileset> </copy> <copy todir="${stage.src.dir}/${final.name}-src/src"> <fileset dir="src" /> </copy>
<zip zipfile="${dist.home}/${final.name}.zip" basedir="${stage.bin.dir}"/> <zip zipfile="${dist.home}/${final.name}-src.zip" basedir="${stage.src.dir}"/> <tar tarfile="${dist.home}/${final.name}.tar" basedir="${stage.bin.dir}" longfile="gnu"/> <tar tarfile="${dist.home}/${final.name}-src.tar" basedir="${stage.src.dir}" longfile="gnu"/> <gzip src="${dist.home}/${final.name}.tar" zipfile="${dist.home}/${final.name}.tar.gz"/> <gzip src="${dist.home}/${final.name}-src.tar" zipfile="${dist.home}/${final.name}-src.tar.gz"/>
<!-- clean up staging directories --> <delete dir="${stage.bin.dir}"/> <delete dir="${stage.src.dir}"/>
</target>
<!-- ========== Gump Target ===================================================== -->
<target name="gump" depends="clean,test,javadoc,jar" description="Gump Target - clean,test,javadoc,jar"/>
<!-- ========== Download Dependencies =========================================== -->
<target name="download-dependencies" depends="check-availability" unless="skip.download"> <echo message="doing download-dependencies..." /> <antcall target="download-junit" /> </target>
<target name="check-availability"> <echo message="doing check-availability..." /> <available file="${download.lib.dir}/junit-${junit.version}.jar" property="junit.found"/> </target>
<target name="download-junit" unless="junit.found"> <echo message="Downloading junit..."/> <mkdir dir="${download.lib.dir}" /> <!-- TODO check hash of jar --> <get dest="${download.lib.dir}" usetimestamp="true" ignoreerrors="true" src="http://repo1.maven.org/maven2/junit/junit/${junit.version}/junit-${junit.version}.jar"/> <get dest="${download.lib.dir}" usetimestamp="true" ignoreerrors="true" src="https://hamcrest.googlecode.com/files/hamcrest-core-1.3.jar"/> </target>
</project>
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051<?xml version="1.0"?><!--Licensed to the Apache Software Foundation (ASF) under one or morecontributor license agreements. See the NOTICE file distributed withthis work for additional information regarding copyright ownership.The ASF licenses this file to You under the Apache License, Version 2.0(the "License"); you may not use this file except in compliance withthe License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License.-->
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.1//EN" "http://www.puppycrawl.com/dtds/configuration_1_1.dtd">
<!-- commons lang customization of default Checkstyle behavior --><module name="Checker"> <property name="localeLanguage" value="en"/> <module name="JavadocPackage"> <!-- setting allowLegacy means it will check for package.html instead of just package-info.java --> <property name="allowLegacy" value="true"/> </module> <module name="FileTabCharacter"> <property name="fileExtensions" value="java,xml"/> </module> <module name="TreeWalker"> <property name="cacheFile" value="target/cachefile"/> <module name="AvoidStarImport"/> <module name="RedundantImport"/> <module name="UnusedImports"/> <module name="NeedBraces"/> <module name="RedundantThrows"> <property name="allowUnchecked" value="true"/> <property name="allowSubclasses" value="true"/> </module> <module name="LineLength"> <property name="max" value="160"/> </module> <module name="JavadocMethod"> <property name="allowUndeclaredRTE" value="true"/> <property name="allowThrowsTagsForSubclasses" value="true"/> </module> </module></module>1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495<?xml version="1.0"?><!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.-->
<!-- This file contains some false positive bugs detected by findbugs. Their false positive nature has been analyzed individually and they have been put here to instruct findbugs it must ignore them.--><FindBugsFilter>
<!-- See discussion on https://issues.apache.org/jira/browse/IO-215 --> <Match> <Class name="org.apache.commons.io.FileUtils" /> <Or> <Method name="doCopyDirectory" params="java.io.File,java.io.File,java.io.FileFilter,boolean,java.util.List" returns="void" /> <Method name="doCopyFile" params="java.io.File,java.io.File,boolean" returns="void" /> </Or> <Bug pattern="RV_RETURN_VALUE_IGNORED_BAD_PRACTICE" /> </Match>
<!-- Ignoring the return from mkdirs() is a false positives since the following line in both those methods checks for the existence of the directory and throws an exception if it doesn't exist. --> <Match> <Class name="org.apache.commons.io.FileUtils" /> <Or> <Method name="moveDirectoryToDirectory" params="java.io.File,java.io.File,boolean" returns="void" /> <Method name="moveFileToDirectory" params="java.io.File,java.io.File,boolean" returns="void" /> </Or> <Bug pattern="RV_RETURN_VALUE_IGNORED_BAD_PRACTICE" /> </Match>
<!-- FileEntry is used internally by FileAlterationObserver to refresh and update the state of files it is monitoring and in that context this is not an issue. If people re-use it elsewhere then they need to take care - but its not its primary purpose here and so its OK --> <Match> <Class name="org.apache.commons.io.monitor.FileEntry" /> <Method name="setChildren" params="org.apache.commons.io.monitor.FileEntry[]" returns="void" /> <Bug pattern="EI_EXPOSE_REP2" /> </Match>
<!-- See discussion on https://issues.apache.org/jira/browse/IO-214 --> <Match> <Class name="org.apache.commons.io.output.ByteArrayOutputStream" /> <Bug pattern="IS2_INCONSISTENT_SYNC" /> </Match>
<!-- This is a false positive since close() does nothing in the Stream implementation being used --> <Match> <Class name="org.apache.commons.io.output.ByteArrayOutputStream" /> <Method name="toBufferedInputStream" params="java.io.InputStream" returns="java.io.InputStream" /> <Bug pattern="OS_OPEN_STREAM" /> </Match>
<!-- See discussion on https://issues.apache.org/jira/browse/IO-216 --> <Match> <Class name="org.apache.commons.io.output.LockableFileWriter" /> <Method name="close" params="" returns="void" /> <Bug pattern="RV_RETURN_VALUE_IGNORED_BAD_PRACTICE" /> </Match>
<Match> <Class name="org.apache.commons.io.output.DeferredFileOutputStream" /> <Or> <Method name="thresholdReached" params="" returns="void" /> </Or> <Bug pattern="OBL_UNSATISFIED_OBLIGATION" /> </Match></FindBugsFilter>123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422<?xml version="1.0"?><!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.--><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <parent> <groupId>org.apache.commons</groupId> <artifactId>commons-parent</artifactId> <version>39</version> </parent> <modelVersion>4.0.0</modelVersion> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> <version>2.5</version> <name>Apache Commons IO</name>
<inceptionYear>2002</inceptionYear> <description>The Apache Commons IO library contains utility classes, stream implementations, file filters, file comparators, endian transformation classes, and much more. </description>
<url>http://commons.apache.org/proper/commons-io/</url>
<issueManagement> <system>jira</system> <url>http://issues.apache.org/jira/browse/IO</url> </issueManagement>
<distributionManagement> <site> <id>apache.website</id> <name>Apache Commons Site</name> <url>scm:svn:https://svn.apache.org/repos/infra/websites/production/commons/content/proper/commons-i/</url> </site> </distributionManagement>
<scm> <connection>scm:svn:http://svn.apache.org/repos/asf/commons/proper/io/tags/commons-io-2.5</connection> <developerConnection>scm:svn:https://svn.apache.org/repos/asf/commons/proper/io/tags/commons-io-2.5</developerConnection> <url>http://svn.apache.org/viewvc/commons/proper/io/tags/commons-io-2.5</url> </scm>
<developers> <developer> <name>Scott Sanders</name> <id>sanders</id> <email>sanders@apache.org</email> <organization /> <roles> <role>Java Developer</role> </roles> </developer> <developer> <name>dIon Gillard</name> <!-- Note: first name is correctly capitalised above --> <id>dion</id> <email>dion@apache.org</email> <organization /> <roles> <role>Java Developer</role> </roles> </developer> <developer> <name>Nicola Ken Barozzi</name> <id>nicolaken</id> <email>nicolaken@apache.org</email> <organization /> <roles> <role>Java Developer</role> </roles> </developer> <developer> <name>Henri Yandell</name> <id>bayard</id> <email>bayard@apache.org</email> <organization /> <roles> <role>Java Developer</role> </roles> </developer> <developer> <name>Stephen Colebourne</name> <id>scolebourne</id> <organization /> <roles> <role>Java Developer</role> </roles> <timezone>0</timezone> </developer> <developer> <name>Jeremias Maerki</name> <id>jeremias</id> <email>jeremias@apache.org</email> <organization /> <roles> <role>Java Developer</role> </roles> <timezone>+1</timezone> </developer> <developer> <name>Matthew Hawthorne</name> <id>matth</id> <email>matth@apache.org</email> <organization /> <roles> <role>Java Developer</role> </roles> </developer> <developer> <name>Martin Cooper</name> <id>martinc</id> <email>martinc@apache.org</email> <organization /> <roles> <role>Java Developer</role> </roles> </developer> <developer> <name>Rob Oxspring</name> <id>roxspring</id> <email>roxspring@apache.org</email> <organization /> <roles> <role>Java Developer</role> </roles> </developer> <developer> <name>Jochen Wiedmann</name> <id>jochen</id> <email>jochen.wiedmann@gmail.com</email> </developer> <developer> <name>Niall Pemberton</name> <id>niallp</id> <roles> <role>Java Developer</role> </roles> </developer> <developer> <name>Jukka Zitting</name> <id>jukka</id> <roles> <role>Java Developer</role> </roles> </developer> <developer> <name>Gary Gregory</name> <id>ggregory</id> <email>ggregory@apache.org</email> <url>http://www.garygregory.com</url> <timezone>-5</timezone> </developer> <developer> <name>Kristian Rosenvold</name> <id>krosenvold</id> <email>krosenvold@apache.org</email> <timezone>+1</timezone> </developer> </developers>
<contributors> <contributor> <name>Rahul Akolkar</name> </contributor> <contributor> <name>Jason Anderson</name> </contributor> <contributor> <name>Nathan Beyer</name> </contributor> <contributor> <name>Emmanuel Bourg</name> </contributor> <contributor> <name>Chris Eldredge</name> </contributor> <contributor> <name>Magnus Grimsell</name> </contributor> <contributor> <name>Jim Harrington</name> </contributor> <contributor> <name>Thomas Ledoux</name> </contributor> <contributor> <name>Andy Lehane</name> </contributor> <contributor> <name>Marcelo Liberato</name> </contributor> <contributor> <name>Alban Peignier</name> <email>alban.peignier at free.fr</email> </contributor> <contributor> <name>Ian Springer</name> </contributor> <contributor> <name>Dominik Stadler</name> </contributor> <contributor> <name>Masato Tezuka</name> </contributor> <contributor> <name>James Urie</name> </contributor> <contributor> <name>Frank W. Zammetti</name> </contributor> </contributors>
<dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> <scope>test</scope> </dependency> </dependencies>
<properties> <maven.compiler.source>1.6</maven.compiler.source> <maven.compiler.target>1.6</maven.compiler.target> <commons.componentid>io</commons.componentid> <commons.rc.version>RC4</commons.rc.version> <commons.release.version>2.5</commons.release.version> <commons.release.desc>(requires JDK 1.6+)</commons.release.desc> <commons.jira.id>IO</commons.jira.id> <commons.jira.pid>12310477</commons.jira.pid> <commons.osgi.export> <!-- Explicit list of packages from IO 1.4 --> org.apache.commons.io; org.apache.commons.io.comparator; org.apache.commons.io.filefilter; org.apache.commons.io.input; org.apache.commons.io.output;version=1.4.9999;-noimport:=true, <!-- Same list plus * for new packages --> org.apache.commons.io; org.apache.commons.io.comparator; org.apache.commons.io.filefilter; org.apache.commons.io.input; org.apache.commons.io.output; org.apache.commons.io.*;version=${project.version};-noimport:=true </commons.osgi.export>
<commons.scmPubCheckoutDirectory>site-content</commons.scmPubCheckoutDirectory> </properties>
<build> <pluginManagement> </pluginManagement> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.14.1</version> <configuration> <classpathDependencyExcludes> <classpathDependencyExclude>xerces:xercesImpl</classpathDependencyExclude> </classpathDependencyExcludes> <forkMode>pertest</forkMode> <!-- limit memory size see IO-161 --> <argLine>-Xmx25M</argLine> <includes> <!-- Only include test classes, not test data --> <include>**/*Test*.class</include> </includes> <excludes> <exclude>**/*AbstractTestCase*</exclude> <exclude>**/testtools/**</exclude> <!-- http://jira.codehaus.org/browse/SUREFIRE-44 --> <exclude>**/*$*</exclude> </excludes> </configuration> </plugin> <plugin> <artifactId>maven-assembly-plugin</artifactId> <configuration> <descriptors> <descriptor>src/assembly/bin.xml</descriptor> <descriptor>src/assembly/src.xml</descriptor> </descriptors> <tarLongFileMode>gnu</tarLongFileMode> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-scm-publish-plugin</artifactId> <configuration> <ignorePathsToDelete> <ignorePathToDelete>javadocs</ignorePathToDelete> </ignorePathsToDelete> </configuration> </plugin> <!-- Configure RAT for CLI invocation: mvn apache-rat:rat --> <plugin> <groupId>org.apache.rat</groupId> <artifactId>apache-rat-plugin</artifactId> <!-- Must agree with report section RAT config --> <configuration> <excludes> <exclude>src/test/resources/**/*.bin</exclude> <exclude>test/**</exclude>
<!-- The next 3 excludes can be dropped when using CP30 --> <exclude>site-content/**</exclude> <exclude>.pmd</exclude> <exclude>src/site/resources/download_*.cgi</exclude>
</excludes> </configuration> </plugin> </plugins> </build>
<reporting> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>cobertura-maven-plugin</artifactId> <version>2.7</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> <version>2.12.1</version> <configuration> <configLocation>${basedir}/checkstyle.xml</configLocation> <enableRulesSummary>false</enableRulesSummary> </configuration> </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>findbugs-maven-plugin</artifactId> <version>${commons.findbugs.version}</version> <configuration> <threshold>Normal</threshold> <effort>Default</effort> <excludeFilterFile>${basedir}/findbugs-exclude-filter.xml</excludeFilterFile> </configuration> </plugin> <plugin> <groupId>org.apache.rat</groupId> <artifactId>apache-rat-plugin</artifactId> <!-- Must agree with build section RAT config --> <configuration> <excludes> <exclude>src/test/resources/**/*.bin</exclude> <exclude>test/**</exclude>
<!-- The next 3 excludes can be dropped when using CP30 --> <exclude>site-content/**</exclude> <exclude>.pmd</exclude> <exclude>src/site/resources/download_*.cgi</exclude>
</excludes> </configuration> </plugin> </plugins> </reporting> <profiles> <profile> <id>setup-checkout</id> <activation> <file> <missing>site-content</missing> </file> </activation> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-antrun-plugin</artifactId> <version>1.8</version> <executions> <execution> <id>prepare-checkout</id> <phase>pre-site</phase> <goals> <goal>run</goal> </goals> <configuration> <target> <exec executable="svn"> <arg line="checkout --depth immediates ${commons.scmPubUrl} ${commons.scmPubCheckoutDirectory}" /> </exec>
<exec executable="svn"> <arg line="update --set-depth exclude ${commons.scmPubCheckoutDirectory}/javadocs" /> </exec>
<pathconvert pathsep=" " property="dirs"> <dirset dir="${commons.scmPubCheckoutDirectory}" includes="*" /> </pathconvert> <exec executable="svn"> <arg line="update --set-depth infinity ${dirs}" /> </exec> </target> </configuration> </execution> </executions> </plugin> </plugins> </build> </profile> </profiles></project>12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.--><assembly> <id>bin</id> <formats> <format>tar.gz</format> <format>zip</format> </formats> <includeSiteDirectory>false</includeSiteDirectory> <fileSets> <fileSet> <includes> <include>LICENSE.txt</include> <include>NOTICE.txt</include> <include>RELEASE-NOTES.txt</include> </includes> </fileSet> <fileSet> <directory>target</directory> <outputDirectory></outputDirectory> <includes> <include>*.jar</include> </includes> </fileSet> <fileSet> <directory>target/site/apidocs</directory> <outputDirectory>docs</outputDirectory> <excludes> <exclude>**/customsorttypes.js</exclude> <exclude>**/sortabletable.js</exclude> <exclude>**/stringbuilder.js</exclude> </excludes> </fileSet> </fileSets></assembly>1234567891011121314151617181920212223242526272829303132333435363738394041<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.--><assembly> <id>src</id> <formats> <format>tar.gz</format> <format>zip</format> </formats> <baseDirectory>${artifactId}-${commons.release.version}-src</baseDirectory> <fileSets> <fileSet> <includes> <include>build.xml</include> <include>checkstyle.xml</include> <include>findbugs-exclude-filter.xml</include> <include>LICENSE.txt</include> <include>NOTICE.txt</include> <include>pom.xml</include> <include>PROPOSAL.html</include> <include>RELEASE-NOTES.txt</include> </includes> </fileSet> <fileSet> <directory>src</directory> </fileSet> </fileSets></assembly>123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488<?xml version="1.0"?><!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.-->
<!--This file is used by the maven-changes-plugin to generate the release notes.Useful ways of finding items to add to this file are:
1. Add items when you fix a bug or add a feature (this makes therelease process easy :-).
2. Do a Jira search for tickets closed since the previous release.
3. Use the report generated by the maven-changelog-plugin to see allCVS commits. Set the project.properties' maven.changelog.rangeproperty to the number of days since the last release.
To generate the release notes from this file:
mvn changes:announcement-generate -Prelease-notes [-Dchanges.version=nnn]
then tweak the source formatting if necessary and regenerate, then commit
The <action> type attribute can be add,update,fix,remove.-->
<document> <properties> <title>Release Notes</title> </properties>
<body> <!-- The release date is the date RC is cut --> <release version="2.5" date="2015-12-DD" description="New features and bug fixes."> <action issue="IO-492" dev="ggregory" type="fix" due-to="Santiago Castro"> Typo: In an IOUtils.java comment it says "focussed" instead of "focused". </action> <action issue="IO-433" dev="krosenvold" type="update"> Converted all testcases to JUnit 4 </action> <action issue="IO-487" dev="bdelacretaz" type="add"> Add ValidatingObjectInputStream for controlled deserialization </action> <action issue="IO-446" dev="krosenvold" type="fix" due-to="Jeffrey Barrus"> adds an endOfFileReached method to the TailerListener </action> <action issue="IO-484" dev="krosenvold" type="fix" due-to="Philippe Arteau"> FilenameUtils should handle embedded null bytes </action> <action issue="IO-481" dev="krosenvold" type="fix"> Changed/Corrected algorithm for waitFor </action> <action issue="IO-471" dev="krosenvold" type="add" due-to="Leandro Reis"> Support for additional encodings in ReversedLinesFileReader </action> <action issue="IO-428" dev="krosenvold" type="fix" due-to="Stefan Gmeiner"> BOMInputStream.skip returns wrong count if stream contains no BOM </action> <action issue="IO-425" dev="krosenvold" type="add" due-to="Craig Swank"> Setter method for threshold on ThresholdingOutputStream </action> <action issue="IO-488" dev="krosenvold" type="fix" due-to="Björn Buchner"> FileUtils.waitFor(...) swallows thread interrupted status </action> <action issue="IO-452" dev="krosenvold" type="fix" due-to="David Standish"> Support for symlinks with missing target. Added support for JDK7 symlink features when present </action> <action issue="IO-466" dev="krosenvold" type="update"> Added testcase to show this was fixed with IO-423 </action> <action issue="IO-479" dev="sebb" type="update" due-to="Zhouce Chen"> Correct exception message in FileUtils.getFile(File, String...) </action> <action issue="IO-406" dev="britter" type="add" due-to="Niall Pemberton"> Introduce new class AppendableOutputStream </action> <action issue="IO-465" dev="britter" type="update" due-to="based2"> Update to JUnit 4.12 </action> <action issue="IO-462" dev="sebb" type="update"> IOExceptionWithCause no longer needed </action> <action issue="IO-459" dev="olamy" type="add" due-to="Kristian Rosenvold"> Add WindowsLineEndingInputStream and UnixLineEndingInputStream. </action> <action issue="IO-457" dev="olamy" type="add" due-to="Kristian Rosenvold"> Add a BoundedReader, a wrapper that can be used to constrain access to an underlying stream when used with mark/reset - to avoid overflowing the mark limit of the underlying buffer. </action> <action issue="IO-453" dev="sebb" type="fix" due-to="Steven Christou"> Regression in FileUtils.readFileToString from 2.0.1 </action> <action issue="IO-451" dev="sebb" type="fix" due-to="David Standish"> ant test fails - resources missing from test classpath </action> <action issue="IO-435" dev="tn" type="fix" due-to="Dominik Stadler"> Document that FileUtils.deleteDirectory, directoryContains and cleanDirectory may throw an IllegalArgumentException in case the passed directory does not exist or is not a directory. </action> <action issue="IO-426" dev="ggregory" type="add"> Add API IOUtils.closeQuietly(Closeable...) </action> <action issue="IO-424" dev="ggregory" type="fix" due-to="Ville Skyttä"> Javadoc fixes, mostly to appease 1.8.0 </action> <action issue="IO-422" dev="ggregory" type="update"> Deprecate Charsets Charset constants in favor of Java 7's java.nio.charset.StandardCharsets </action> <action issue="IO-410" dev="sebb" type="add" due-to="Beluga Behr"> Readfully() That Returns A Byte Array </action> <action issue="IO-395" dev="brentworden" type="add" due-to="Beluga Behr"> Overload IOUtils buffer methods to accept buffer size </action> <action issue="IO-389" dev="sebb" type="fix" due-to="Austin Doupnik"> FileUtils.sizeOfDirectory can throw IllegalArgumentException </action> <action issue="IO-390" dev="sebb" type="fix"> FileUtils.sizeOfDirectoryAsBigInteger can overflow. Ensure that recursive calls all use BigInteger </action> <action issue="IO-382" dev="sebb" type="add"> Chunked IO for large arrays. Added writeChunked(byte[], OutputStream) and writeChunked(char[] Writer) Added ChunkedOutputStream, ChunkedWriter </action> <action issue="IO-385" dev="sebb" type="fix"> FileUtils.doCopyFile can potentially loop for ever Exit loop if no data to copy </action> <action issue="IO-383" dev="sebb" type="fix"> FileUtils.doCopyFile caches the file size; needs to be documented Added Javadoc; show file lengths in exception message </action> <action issue="IO-239" dev="sebb" type="update"> Convert IOCase to a Java 1.5+ Enumeration [N.B. this is binary compatible] </action> <action issue="IO-233" dev="sebb" type="add"> Add Methods for Buffering Streams/Writers To IOUtils Added overloaded buffer() methods - see also IO-330 </action> <action issue="IO-330" dev="sebb" type="add"> IOUtils#toBufferedOutputStream/toBufferedWriter to conditionally wrap the output Added overloaded buffer() methods - see also IO-233 </action> <action issue="IO-381" dev="ggregory" type="add"> Add FileUtils.copyInputStreamToFile API with option to leave the source open. See copyInputStreamToFile(final InputStream source, final File destination, boolean closeSource) </action> <action issue="IO-380" dev="sebb" type="fix" due-to="claudio_ch"> FileUtils.copyInputStreamToFile should document it closes the input source </action> <action issue="IO-279" dev="sebb" type="fix"> Tailer erroneously considers file as new. Fix to use file.lastModified() rather than System.currentTimeMillis() </action> <action issue="IO-356" dev="sebb" type="fix"> CharSequenceInputStream#reset() behaves incorrectly in case when buffer size is not dividable by data size. Fix code so skip relates to the encoded bytes; reset now re-encodes the data up to the point of the mark </action> <action issue="IO-379" dev="sebb" type="add"> CharSequenceInputStream - add tests for available() Fix code so it really does reflect a minimum available. </action> <action issue="IO-328" dev="sebb" type="update"> getPrefixLength returns null if filename has leading slashes Javadoc: add examples to show correct behaviour; add unit tests </action> <action issue="IO-299" dev="sebb" type="update"> FileUtils.listFilesAndDirs includes original dir in results even when it doesn't match filter Javadoc: clarify that original dir is included in the results </action> <action issue="IO-346" dev="sebb" type="add"> Add ByteArrayOutputStream.toInputStream() </action> <action issue="IO-368" dev="sebb" type="fix"> ClassLoaderObjectInputStream does not handle primitive typed members </action> <action issue="IO-341" dev="sebb" type="add"> A constant for holding the BOM character (U+FEFF) </action> <action issue="IO-314" dev="sebb" type="fix"> Deprecate all methods that use the default encoding </action> <action issue="IO-338" dev="sebb" type="fix"> When a file is rotated, finish reading previous file prior to starting new one </action> <action issue="IO-354" dev="sebb" type="fix"> Commons IO Tailer does not respect UTF-8 Charset. </action> <action issue="IO-323" dev="sebb" type="fix"> What should happen in FileUtils.sizeOf[Directory] when an overflow takes place? Added Javadoc. </action> <action issue="IO-372" dev="sebb" type="fix"> FileUtils.moveDirectory can produce misleading error message on failiure </action> <action issue="IO-375" dev="sebb" type="update"> FilenameUtils.splitOnTokens(String text) check for '**' could be simplified </action> <action issue="IO-374" dev="sebb" type="update"> WildcardFileFilter ctors should not use null to mean IOCase.SENSITIVE when delegating to other ctors </action> <action issue="IO-362" dev="ggregory" type="fix" due-to="mmadson, ggregory"> IOUtils.contentEquals* methods returns false if input1 == input2, should return true. </action> <action issue="IO-361" dev="ggregory" type="add"> Add API FileUtils.forceMkdirsParent(). </action> <action issue="IO-360" dev="ggregory" type="add"> Add API Charsets.requiredCharsets(). </action> <action issue="IO-359" dev="ggregory" type="add" due-to="yukoba"> Add IOUtils.skip and skipFully(ReadableByteChannel, long). </action> <action issue="IO-358" dev="ggregory" type="add" due-to="yukoba"> Add IOUtils.read and readFully(ReadableByteChannel, ByteBuffer buffer). </action> <action issue="IO-357" dev="ggregory" type="fix" due-to="mortenh"> [Tailer] InterruptedException while the thread is sleeping is silently ignored </action> <action issue="IO-353" dev="ggregory" type="add" due-to="ggregory"> Add API IOUtils.copy(InputStream, OutputStream, int) </action> <action issue="IO-349" dev="ggregory" type="add" due-to="scop"> Add API with array offset and length argument to FileUtils.writeByteArrayToFile. </action> <action issue="IO-352" dev="ggregory" type="fix" due-to="scop"> Spelling fixes. </action> <action issue="IO-348" dev="ggregory" type="add" due-to="plcstpierre"> Missing information in IllegalArgumentException thrown by org.apache.commons.io.FileUtils#validateListFilesParameters. </action> <action issue="IO-345" dev="ggregory" type="add" due-to="mkresse"> Supply a hook method allowing Tailer actively determining stop condition. </action> <action issue="IO-436" dev="ggregory" type="fix" due-to="christoph.schneegans"> Improper JavaDoc comment for FilenameUtils.indexOfExtension. </action> <action issue="IO-437" dev="ggregory" type="add"> Make IOUtils.EOF public and reuse it in various classes. </action> </release> <!-- The release date is the date RC is cut --> <release version="2.4" date="2012-06-12" description="New features and bug fixes."> <action issue="IO-343" dev="ggregory" type="fix" due-to="igorlash"> org.apache.commons.io.comparator Javadoc is inconsistent with real code. </action> <action issue="IO-336" dev="ggregory" type="fix" due-to="rleavelle"> Yottabyte (YB) incorrectly defined in FileUtils. </action> <action issue="IO-269" dev="ggregory" type="add" due-to="sebb"> Tailer locks file from deletion/rename on Windows. </action> <action issue="IO-279" dev="sebb" type="fix" due-to="Sergio Bossa, Chris Baron"> Tailer erroneously considers file as new. </action> <action issue="IO-335" dev="sebb" type="fix"> Tailer#readLines - incorrect CR handling. </action> <action issue="IO-334" dev="sebb" type="fix"> FileUtils.toURLs throws NPE for null parameter; document the behavior. </action> <action issue="IO-333" dev="ggregory" type="add" due-to="fmeschbe"> Export OSGi packages at version 1.x in addition to 2.x. </action> <action issue="IO-320" dev="ggregory" type="add" due-to="ggregory"> Add XmlStreamReader support for UTF-32. </action> <action issue="IO-331" dev="ggregory" type="add" due-to="ggregory"> BOMInputStream wrongly detects UTF-32LE_BOM files as UTF-16LE_BOM files in method getBOM(). </action> <action issue="IO-332" dev="ggregory" type="fix" due-to="liangly"> Improve tailer's reading performance. </action> <action issue="IO-279" dev="ggregory" type="fix"> Improve Tailer performance with buffered reads (see IO-332). </action> <action issue="IO-329" dev="ggregory" type="fix" due-to="tivv"> FileUtils.writeLines uses unbuffered IO. </action> <action issue="IO-327" dev="ggregory" type="add" due-to="ggregory"> Add byteCountToDisplaySize(BigInteger). </action> <action issue="IO-326" dev="ggregory" type="add" due-to="ggregory, kinow"> Add new FileUtils.sizeOf[Directory] APIs to return BigInteger. </action> <action issue="IO-325" dev="ggregory" type="add" due-to="raviprak"> Add IOUtils.toByteArray methods to work with URL and URI. </action> <action issue="IO-324" dev="ggregory" type="add" due-to="raviprak"> Add missing Charset sister APIs to method that take a String charset name. </action> <action issue="IO-319" dev="ggregory" type="fix" due-to="raviprak"> FileUtils.sizeOfDirectory follows symbolic links. </action> </release> <!-- The release date is the date RC is cut --> <release version="2.3" date="2012-April-10" description="New features and bug fixes."> <action issue="IO-322" dev="ggregory" type="add" due-to="ggregory"> Add and use class Charsets. </action> <action issue="IO-321" dev="ggregory" type="add" due-to="ggregory"> ByteOrderMark UTF_32LE is incorrect. </action> <action issue="IO-318" dev="ggregory" type="add" due-to="ggregory"> Add Charset sister APIs to method that take a String charset name. </action> </release> <release version="2.2" date="2012-March-26" description="New features and bug fixes."> <action issue="IO-313" dev="ggregory" type="add" due-to="ggregory"> Add IOUTils.toBufferedReader(Reader) </action> <!-- Note: the issue was not raised by Manoj, but arose from IO-305 and tests he performed --> <action issue="IO-308" dev="sebb" type="add" due-to="Manoj Mokashi"> Allow applications to provide buffer (or size) for copyLarge methods. </action> <action issue="IO-311" dev="sebb" type="fix" due-to="Robert Muir"> IOUtils.read(InputStream/Reader) ignores the offset parameter </action> <action issue="IO-312" dev="sebb" type="fix"> CharSequenceInputStream(CharSequence s, Charset charset, int bufferSize) ignores bufferSize </action> <action issue="IO-305" dev="sebb" type="add" due-to="Manoj Mokashi"> New copyLarge() method in IOUtils that takes additional offset, length arguments </action> <action issue="IO-300" dev="sebb" type="fix"> FileUtils.moveDirectoryToDirectory removes source directory if destination is a sub-directory </action> <action issue="IO-307" dev="sebb" type="fix"> ReaderInputStream#read(byte[] b, int off, int len) should check for valid parameters </action> <action issue="IO-287" dev="bayard" type="add" due-to="Ron Kuris, Gary Gregory"> Use terabyte (TB), petabyte (PB) and exabyte (EB) in FileUtils.byteCountToDisplaySize(long size) </action> <action issue="IO-306" dev="sebb" type="fix"> ReaderInputStream#read(byte[] b, int off, int len) should always return 0 for length == 0 </action> <action issue="IO-173" dev="sebb" type="add" due-to="Marcos Vinícius da Silva"> FileUtils.listFiles() doesn't return directories </action> <action issue="IO-276" dev="sebb" type="fix" due-to="nkami"> "FileUtils#deleteDirectoryOnExit(File)" does not work </action> <action issue="IO-273" dev="sebb" type="fix" due-to="sebb"> BoundedInputStream.read() treats max differently from BoundedInputStream.read(byte[]...) </action> <action issue="IO-297" dev="sebb" type="add" due-to="Oleg Kalnichevski"> CharSequenceInputStream to efficiently stream content of a CharSequence </action> <action issue="IO-296" dev="sebb" type="update" due-to="Oleg Kalnichevski"> ReaderInputStream optimization: more efficient reading of small chunks of data </action> <action issue="IO-298" dev="sebb" type="fix" due-to="Christian Schulte"> Various methods of class 'org.apache.commons.io.FileUtils' incorrectly suppress 'java.io.IOException' </action> <action issue="IO-304" dev="ggregory" type="add" due-to="liangly"> The second constructor of Tailer class does not pass 'delay' to the third one </action> <action issue="IO-303" dev="ggregory" type="add" due-to="fabian.barney"> TeeOutputStream does not call branch.close() when main.close() throws an exception </action> <action issue="IO-302" dev="ggregory" type="add" due-to="jsteuerwald, detinho"> ArrayIndexOutOfBoundsException in BOMInputStream when reading a file without BOM multiple times </action> <action issue="IO-301" dev="ggregory" type="add" due-to="kaykay.unique"> Add IOUtils.closeQuietly(Selector) necessary </action> <action issue="IO-292" dev="sebb" type="add" due-to="sebb"> IOUtils.closeQuietly() should take a ServerSocket as a parameter </action> <action issue="IO-290" dev="sebb" type="add" due-to="sebb"> Add read/readFully methods to IOUtils </action> <action issue="IO-288" dev="sebb" type="add" due-to="Georg Henzler"> Supply a ReversedLinesFileReader </action> <action issue="IO-291" dev="ggregory" type="add" due-to="ggregory"> Add new function FileUtils.directoryContains. </action> <action issue="IO-275" dev="sebb" type="add" due-to="CJ Aspromgos"> FileUtils.contentEquals and IOUtils.contentEquals - Add option to ignore "line endings" Added contentEqualsIgnoreEOL methods to both classes </action> </release> <release version="2.1" date="2011-Sep-28" description="New features and bug fixes."> <action dev="ggregory" type="add" issue="IO-285" due-to="ggregory"> Use standard Maven directory layout </action> <action dev="ggregory" type="add" issue="IO-284" due-to="ggregory"> Add IOUtils API toString for URL and URI to get contents </action> <action dev="ggregory" type="add" issue="IO-282" due-to="ggregory"> Add API FileUtils.copyFile(File input, OutputStream output) </action> <action dev="sebb" type="fix" issue="IO-280" due-to="sebb"> Dubious use of mkdirs() return code </action> <action type="fix" issue="IO-277"> ReaderInputStream enters infinite loop when it encounters an unmappable character </action> <action type="fix" issue="IO-264"> FileUtils.moveFile() JavaDoc should specify FileExistsException thrown </action> <action type="add" issue="IO-262"> FileAlterationObserver has no getter for FileFilter </action> <action type="add" issue="IO-261"> Add FileUtils.getFile API with varargs parameter </action> <action type="fix" issue="IO-260"> ClassLoaderObjectInputStream does not handle Proxy classes </action> <action type="update" issue="IO-259"> FileAlterationMonitor.stop(boolean allowIntervalToFinish) </action> <action type="add" issue="IO-182"> Add new APPEND parameter for writing string into files </action> <action dev="sebb" type="fix" issue="IO-274" due-to="Frank Grimes"> Tailer returning partial lines when reaching EOF before EOL </action> <action dev="sebb" type="fix" issue="IO-266" due-to="Igor Smereka"> FileUtils.copyFile() throws IOException when copying large files to a shared directory (on Windows) </action> <action dev="sebb" type="fix" issue="IO-263" due-to="Gil Adam"> FileSystemUtils.freeSpaceKb throws exception for Windows volumes with no visible files. Improve coverage by also looking for hidden files. </action> <action dev="sebb" type="add" issue="IO-251" due-to="Marco Albini"> Add new read method "toByteArray" to handle InputStream with known size. </action>
</release>
<release version="2.0.1" date="2010-Dec-26"> <action type="update"> TODO: Convert RELEASE-NOTES.txt from 2.0.1? </action> </release>
<release version="2.0" date="2010-Oct-18"> <action type="update"> TODO: Convert RELEASE-NOTES.txt from 2.0? </action> </release>
<release version="1.4" date="2008-Jan-21"> <action type="update"> TODO: Convert RELEASE-NOTES.txt from 1.4? </action> </release>
<release version="1.3.2" date="2007-Jul-02" description="Bug fixes."> <action dev="jochen" type="fix" issue="IO-115"> Some tests, which are implicitly assuming a Unix-like file system, are now skipped on Windows. </action> <action dev="jochen" type="fix" issue="IO-116"> Created the FileCleaningTracker, basically a non-static version of the FileCleaner, which can be controlled by the user. </action> <action dev="bayard" type="fix" issue="IO-117" due-to="Hiroshi Ikeda"> EndianUtils - both readSwappedUnsignedInteger(...) methods could return negative numbers due to int/long casting. </action> </release> </body></document>123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029## Licensed to the Apache Software Foundation (ASF) under one## or more contributor license agreements. See the NOTICE file## distributed with this work for additional information## regarding copyright ownership. The ASF licenses this file## to you under the Apache License, Version 2.0 (the## "License"); you may not use this file except in compliance## with the License. You may obtain a copy of the License at#### http://www.apache.org/licenses/LICENSE-2.0#### Unless required by applicable law or agreed to in writing,## software distributed under the License is distributed on an## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY## KIND, either express or implied. See the License for the## specific language governing permissions and limitations## under the License.
Apache Commons IO Version ${version}Release Notes
INTRODUCTION:
Commons IO is a package of Java utility classes like java.io. Classes in this package are considered to be so standard and of such high reuse as to justify existence in java.io.
$introduction.replaceAll("(?<!\015)\012", "")
==============================================================================Apache Commons IO Version ${version}==============================================================================#### N.B. the available variables are described here:## http://maven.apache.org/plugins/maven-changes-plugin/examples/using-a-custom-announcement-template.html#### Hack to improve layout: replace all pairs of spaces with a single new-line$release.description.replaceAll(" ", "")
###if ($release.getActions().size() == 0)No changes defined in this version.#elseChanges in this version include:
## indent to be used if there is no issue attribute.## should be the same as the indent in the changes.xml file## less 2 spaces for the 'o' and trailing space#set($indent=' ')#if ($release.getActions('add').size() !=0)New features:#foreach($actionItem in $release.getActions('add'))## Use replaceAll to fix up LF-only line ends on Windows.#set($action=$actionItem.getAction().replaceAll("\n",""))#if ($actionItem.getIssue())#set($issue=$actionItem.getIssue())#else#set($issue="")#end#if ($actionItem.getDueTo())#set($dueto=$actionItem.getDueTo())#else#set($dueto="")#endo#if($!issue != "") $issue: #else$indent#end ${action} #if($!dueto != "")Thanks to $dueto. #end
#set($issue="")#set($dueto="")#end #end
#if ($release.getActions('fix').size() !=0)Fixed Bugs:#foreach($actionItem in $release.getActions('fix'))## Use replaceAll to fix up LF-only line ends on Windows.#set($action=$actionItem.getAction().replaceAll("\n",""))#if ($actionItem.getIssue())#set($issue=$actionItem.getIssue())#else#set($issue="")#end#if ($actionItem.getDueTo())#set($dueto=$actionItem.getDueTo())#else#set($dueto="")#endo#if($!issue != "") $issue: #else$indent#end ${action} #if($!dueto != "")Thanks to $dueto. #end
#set($issue="")#set($dueto="")#end#end
#if ($release.getActions('update').size() !=0)Changes:#foreach($actionItem in $release.getActions('update'))## Use replaceAll to fix up LF-only line ends on Windows.#set($action=$actionItem.getAction().replaceAll("\n",""))#if ($actionItem.getIssue())#set($issue=$actionItem.getIssue())#else#set($issue="")#end#if ($actionItem.getDueTo())#set($dueto=$actionItem.getDueTo())#else#set($dueto="")#endo#if($!issue != "") $issue: #else$indent#end ${action} #if($!dueto != "")Thanks to $dueto. #end
#set($issue="")#set($dueto="")#end#end
#if ($release.getActions('remove').size() !=0)Removed:#foreach($actionItem in $release.getActions('remove'))## Use replaceAll to fix up LF-only line ends on Windows.#set($action=$actionItem.getAction().replaceAll("\n",""))#if ($actionItem.getIssue())#set($issue=$actionItem.getIssue())#else#set($issue="")#end#if ($actionItem.getDueTo())#set($dueto=$actionItem.getDueTo())#else#set($dueto="")#endo#if($!issue != "") $issue: #else$indent#end ${action} #if($!dueto != "")Thanks to $dueto. #end###set($issue="")#set($dueto="")#end#end## End of main loop#end##Compatibility with 2.4:Binary compatible: Yes.Source compatible: Yes.Semantic compatible: Yes.
Compatibility with 2.2 and 1.4:Binary compatible: Yes.Source compatible: No, see the rare case in https://issues.apache.org/jira/browse/IO-318.Semantic compatible: No, see the rare case in https://issues.apache.org/jira/browse/IO-318.
Commons IO 2.5 requires JDK 1.6 or later.Commons IO 2.4 requires JDK 1.6 or later.Commons IO 2.3 requires JDK 1.6 or later.Commons IO 2.2 requires JDK 1.5 or later.Commons IO 1.4 requires JDK 1.3 or later.
==============================================================================Apache Commons IO Version 2.4==============================================================================
Changes in this version include:
New features:o IO-269: Tailer locks file from deletion/rename on Windows. Thanks tosebb.o IO-333: Export OSGi packages at version 1.x in addition to 2.x. Thanksto fmeschbe.o IO-320: Add XmlStreamReader support for UTF-32. Thanks to ggregory.o IO-331: BOMInputStream wrongly detects UTF-32LE_BOM files asUTF-16LE_BOM files in method getBOM(). Thanks to ggregory.o IO-327: Add byteCountToDisplaySize(BigInteger). Thanks to ggregory.o IO-326: Add new FileUtils.sizeOf[Directory] APIs to return BigInteger.Thanks to ggregory.o IO-325: Add IOUtils.toByteArray methods to work with URL and URI. Thanksto raviprak.o IO-324: Add missing Charset sister APIs to method that take a Stringcharset name. Thanks to raviprak.
Fixed Bugs:o IO-336: Yottabyte (YB) incorrectly defined in FileUtils. Thanks torleavelle.o IO-279: Tailer erroneously considers file as new. Thanks to SergioBossa, Chris Baron.o IO-335: Tailer#readLines - incorrect CR handling.o IO-334: FileUtils.toURLs throws NPE for null parameter; document thebehavior.o IO-332: Improve tailer's reading performance. Thanks to liangly.o IO-279: Improve Tailer performance with buffered reads (see IO-332).o IO-329: FileUtils.writeLines uses unbuffered IO. Thanks to tivv.o IO-319: FileUtils.sizeOfDirectory follows symbolic links. Thanks toraviprak.
Compatibility with 2.3:Binary compatible: Yes.Source compatible: Yes.Semantic compatible: Yes.
Compatibility with 2.2 and 1.4:Binary compatible: Yes.Source compatible: No, see the rare case in https://issues.apache.org/jira/browse/IO-318.Semantic compatible: No, see the rare case in https://issues.apache.org/jira/browse/IO-318.
Commons IO 2.4 requires JDK 1.6 or later.Commons IO 2.3 requires JDK 1.6 or later.Commons IO 2.2 requires JDK 1.5 or later.Commons IO 1.4 requires JDK 1.3 or later.
==============================================================================Apache Commons IO Version 2.3==============================================================================
Changes in this version include:
New features:o IO-322: Add and use class Charsets. Thanks to ggregory. o IO-321: ByteOrderMark UTF_32LE is incorrect. Thanks to ggregory. o IO-318: Add Charset sister APIs to method that take a String charset name. Thanks to ggregory.
Compatibility with 2.2 and 1.4:Binary compatible: Yes.Source compatible: No, see the rare case in https://issues.apache.org/jira/browse/IO-318.Semantic compatible: No, see the rare case in https://issues.apache.org/jira/browse/IO-318.
Commons IO 2.3 requires JDK 1.6 or later.Commons IO 2.2 requires JDK 1.5 or later.Commons IO 1.4 requires JDK 1.3 or later.
==============================================================================Apache Commons IO Version 2.2==============================================================================
Changes in this version include:
New features:o Add IOUTils.toBufferedReader(Reader) Issue: IO-313. Thanks to ggregory. o Allow applications to provide buffer (or size) for copyLarge methods. Issue: IO-308. Thanks to Manoj Mokashi. o New copyLarge() method in IOUtils that takes additional offset, length arguments Issue: IO-305. Thanks to Manoj Mokashi. o Use terabyte (TB), petabyte (PB) and exabyte (EB) in FileUtils.byteCountToDisplaySize(long size) Issue: IO-287. Thanks to Ron Kuris, Gary Gregory. o FileUtils.listFiles() doesn't return directories Issue: IO-173. Thanks to Marcos Vin�cius da Silva. o CharSequenceInputStream to efficiently stream content of a CharSequence Issue: IO-297. Thanks to Oleg Kalnichevski. o The second constructor of Tailer class does not pass 'delay' to the third one Issue: IO-304. Thanks to liangly. o TeeOutputStream does not call branch.close() when main.close() throws an exception Issue: IO-303. Thanks to fabian.barney. o ArrayIndexOutOfBoundsException in BOMInputStream when reading a file without BOM multiple times Issue: IO-302. Thanks to jsteuerwald, detinho. o Add IOUtils.closeQuietly(Selector) necessary Issue: IO-301. Thanks to kaykay.unique. o IOUtils.closeQuietly() should take a ServerSocket as a parameter Issue: IO-292. Thanks to sebb. o Add read/readFully methods to IOUtils Issue: IO-290. Thanks to sebb. o Supply a ReversedLinesFileReader Issue: IO-288. Thanks to Georg Henzler. o Add new function FileUtils.directoryContains. Issue: IO-291. Thanks to ggregory. o FileUtils.contentEquals and IOUtils.contentEquals - Add option to ignore "line endings" Added contentEqualsIgnoreEOL methods to both classes Issue: IO-275. Thanks to CJ Aspromgos.
Fixed Bugs:o IOUtils.read(InputStream/Reader) ignores the offset parameter Issue: IO-311. Thanks to Robert Muir. o CharSequenceInputStream(CharSequence s, Charset charset, int bufferSize) ignores bufferSize Issue: IO-312. o FileUtils.moveDirectoryToDirectory removes source directory if destination is a subdirectory Issue: IO-300. o ReaderInputStream#read(byte[] b, int off, int len) should check for valid parameters Issue: IO-307. o ReaderInputStream#read(byte[] b, int off, int len) should always return 0 for length == 0 Issue: IO-306. o "FileUtils#deleteDirectoryOnExit(File)" does not work Issue: IO-276. Thanks to nkami. o BoundedInputStream.read() treats max differently from BoundedInputStream.read(byte[]...) Issue: IO-273. Thanks to sebb. o Various methods of class 'org.apache.commons.io.FileUtils' incorrectly suppress 'java.io.IOException' Issue: IO-298. Thanks to Christian Schulte.
Changes:o ReaderInputStream optimization: more efficient reading of small chunks of data Issue: IO-296. Thanks to Oleg Kalnichevski.
Compatibility with 2.1 and 1.4:Binary compatible: YesSource compatible: YesSemantic compatible: Yes. Check the bug fixes section for semantic bug fixes
Commons IO 2.2 requires a minimum of JDK 1.5. Commons IO 1.4 requires a minimum of JDK 1.3.
==============================================================================Apache Commons IO Version 2.1==============================================================================
New features:o Use standard Maven directory layout Issue: IO-285. Thanks to ggregory. o Add IOUtils API toString for URL and URI to get contents Issue: IO-284. Thanks to ggregory. o Add API FileUtils.copyFile(File input, OutputStream output) Issue: IO-282. Thanks to ggregory. o FileAlterationObserver has no getter for FileFilter Issue: IO-262. o Add FileUtils.getFile API with varargs parameter Issue: IO-261. o Add new APPEND parameter for writing string into files Issue: IO-182. o Add new read method "toByteArray" to handle InputStream with known size. Issue: IO-251. Thanks to Marco Albini.
Fixed Bugs:o Dubious use of mkdirs() return code Issue: IO-280. Thanks to sebb. o ReaderInputStream enters infinite loop when it encounters an unmappable character Issue: IO-277. o FileUtils.moveFile() JavaDoc should specify FileExistsException thrown Issue: IO-264. o ClassLoaderObjectInputStream does not handle Proxy classes Issue: IO-260. o Tailer returning partial lines when reaching EOF before EOL Issue: IO-274. Thanks to Frank Grimes. o FileUtils.copyFile() throws IOException when copying large files to a shared directory (on Windows) Issue: IO-266. Thanks to Igor Smereka. o FileSystemUtils.freeSpaceKb throws exception for Windows volumes with no visible files. Improve coverage by also looking for hidden files. Issue: IO-263. Thanks to Gil Adam.
Changes:o FileAlterationMonitor.stop(boolean allowIntervalToFinish) Issue: IO-259.
==============================================================================Apache Commons IO Package 2.0.1==============================================================================
Compatibility with 2.0 and 1.4------------------------------Binary compatible - Yes
Source compatible - Yes
Semantic compatible - Yes Check the bug fixes section for semantic bug fixes
Commons IO 2.0.1 requires a minimum of JDK 1.5 (Commons IO 1.4 had a minimum of JDK 1.3)
Enhancements from 2.0---------------------
* [IO-256] - Provide thread factory for FileAlternationMonitor
Bug fixes from 2.0------------------
* [IO-257] - BOMInputStream.read(byte[]) can return 0 which it should not * [IO-258] - XmlStreamReader consumes the stream during encoding detection
==============================================================================Apache Commons IO Package 2.0==============================================================================
Compatibility with 1.4----------------------Binary compatible - Yes
Source compatible - Yes
Semantic compatible - Yes Check the bug fixes section for semantic bug fixes
Commons IO 2.0 requires a minimum of JDK 1.5 (Commons IO 1.4 had a minimum of JDK 1.3)
Deprecations from 1.4---------------------
- IOUtils - write(StringBuffer, Writer) in favour of write(CharSequence, Writer) - write(StringBuffer, OutputStream) in favour of write(CharSequence, OutputStream) - write(StringBuffer, OutputStream, String) in favour of write(CharSequence, OutputStream, String)
- FileFilterUtils - andFileFilter(IOFileFilter, IOFileFilter) in favour of and(IOFileFilter...) - orFileFilter(IOFileFilter, IOFileFilter) in favour of or(IOFileFilter...)
Enhancements from 1.4---------------------
* [IO-140] Move minimum Java requirement from JDK 1.3 to JDK 1.5 - use Generics - add new CharSequence write() flavour methods to IOUtils and FileUtils - replace StringBuffer with StringBuilder, where appropriate - add new Reader/Writer methods to ProxyReader and ProxyWriter - Annotate with @Override and @Deprecated
* [IO-178] New BOMInputStream and ByteOrderMark implementations - to detect and optionally exclude an initial Byte Order mark (BOM) * [IO-197] New BoundedInputStream (copied from from Apache JackRabbit) * [IO-193] New Broken Input and Output streams * [IO-132] New File Listener/Monitor facility * [IO-158] New ReaderInputStream and WriterOutputStream implementations * [IO-139] New StringBuilder Writer implementation * [IO-192] New Tagged Input and Output streams * [IO-177] New Tailer class - simple implementation of the Unix "tail -f" functionality * [IO-162] New XML Stream Reader/Writer implementations (from ROME via plexus-utils)
* [IO-142] Comparators - add facility to sort file lists/arrays * [IO-186] Comparators - new Composite and Directory File Comparator implementations * [IO-176] DirectoryWalker - add filterDirectoryContents() callback method for filtering directory contents * [IO-210] FileFilter - new Magic Number FileFilter * [IO-221] FileFilterUtils - add methods for suffix and prefix filters which take an IOCase object * [IO-232] FileFilterUtils - add method for name filters which take an IOCase object * [IO-229] FileFilterUtils - add varargs and() and or() methods * [IO-198] FileFilterUtils - add ability to apply file filters to collections and arrays * [IO-156] FilenameUtils - add normalize() and normalizeNoEndSeparator() methods which allow the separator character to be specified * [IO-194] FileSystemUtils - add freeSpaceKb() method with no input arguments * [IO-185] FileSystemUtils - add freeSpaceKb() methods that take a timeout parameter - fixes freeSpaceWindows() blocks * [IO-155] FileUtils - use NIO to copy files * [IO-168] FileUtils - add new isSymlink() method * [IO-219] FileUtils - throw FileExistsException when moving a file or directory if the destination already exists * [IO-234] FileUtils - add Methods for retrieving System User/Temp directories/paths * [IO-208] FileUtils - add timeout (connection and read) support for copyURLToFile() method * [IO-238] FileUtils - add sizeOf(File) method * [IO-181] LineIterator now implements Iterable * [IO-224] IOUtils - add closeQuietly(Closeable) and closeQuietly(Socket) methods * [IO-203] IOUtils - add skipFully() method for InputStreams * [IO-137] IOUtils and ByteArrayOutputStream - add toBufferedInputStream() method to avoid unnecessary array allocation/copy * [IO-195] Proxy streams/Reader/Writer - provide exception handling methods * [IO-211] Proxy Input/Output streams - add pre/post processing support * [IO-242] Proxy Reader/Writer - add pre/post processing support
Bug fixes from 1.4------------------ * [IO-214] ByteArrayOutputStream - fix inconsistent synchronization of fields * [IO-201] Counting Input/Output streams - fix inconsistent synchronization * [IO-159] FileCleaningTracker - fix remove() never returns null * [IO-220] FileCleaningTracker - fix Vector performs badly under load * [IO-167] FilenameUtils - fix case-insensitive string handling in FilenameUtils and FilesystemUtils * [IO-179] FilenameUtils - fix StringIndexOutOfBounds exception in getPathNoEndSeparator() * [IO-248] FilenameUtils - fix getFullPathNoEndSeparator() returns empty while path is a one level directory * [IO-246] FilenameUtils - fix wildcardMatch gives incorrect results * [IO-187] FileSystemUtils - fix freeSpaceKb() doesn't work with relative paths on Linux * [IO-160] FileSystemUtils - fix freeSpace() fails on solaris * [IO-209] FileSystemUtils - fix freeSpaceKb() fails to return correct size for a windows mount point * [IO-163] FileUtils - fix toURLs() using deprecated method of conversion to URL * [IO-168] FileUtils - fix Symbolic links followed when deleting directory * [IO-231] FileUtils - fix wrong exception message generated in isFileNewer() method * [IO-207] FileUtils - fix race condition in forceMkdir() method * [IO-217] FileUtils - fix copyDirectoryToDirectory() makes infinite loops * [IO-166] FileUtils - fix URL decoding in toFile(URL) * [IO-190] FileUtils - fix copyDirectory not preserving lastmodified date on sub-directories * [IO-240] FileFilterUtils - ensure cvsFilter and svnFilter are only created once. * [IO-175] IOUtils - fix copyFile() issues with very large files * [IO-191] Improvements from static analysis * [IO-216] LockableFileWriter - delete files quietly when an exception is thrown during initialization * [IO-243] SwappedDataInputStream - fix readBoolean is inverted * [IO-235] Tests - remove unused YellOnFlushAndCloseOutputStream from CopyUtilsTest * [IO-161] Tests - fix FileCleaningTrackerTestCase hanging
Documentation changes from 1.4------------------------------ * [IO-183 FilenameUtils.getExtension() method documentation improvements * [IO-226 FileUtils.byteCountToDisplaySize() documentation corrections * [IO-205 FileUtils.forceMkdir() documentation improvements * [IO-215 FileUtils copy file/directory improve documentation regarding preserving the last modified date * [IO-189 HexDump.dump() method documentation improvements * [IO-171 IOCase document that it assumes there are only two OSes: Windows and Unix * [IO-223 IOUtils.copy() documentation corrections * [IO-247 IOUtils.closeQuietly() improve documentation with examples * [IO-202 NotFileFilter documentation corrections * [IO-206 ProxyInputStream - fix misleading parameter names * [IO-212 ProxyInputStream.skip() documentation corrections
==============================================================================Apache Commons IO Version 1.4==============================================================================
Compatibility with 1.3.2------------------------Binary compatible - Yes
Source compatible - Yes
Semantic compatible - Yes Check the bug fixes section for semantic bug fixes
Commons IO 1.4 introduces four new implementations which depend on JDK 1.4 features(CharSequenceReader, FileWriterWithEncoding, IOExceptionWithCause and RegexFileFilter).It has been built with the JDK source and target options set to JDK 1.3 and, except forthose implementations, can be used with JDK 1.3 (see IO IO-127).
Deprecations from 1.3.2------------------------ FileCleaner deprecated in favour of FileCleaningTracker [see IO-116]
Bug fixes from 1.3.2--------------------- FileUtils - forceDelete of orphaned Softlinks does not work [IO-147] - Infinite loop on FileUtils.copyDirectory when the destination directory is within the source directory [IO-141] - Add a copyDirectory() method that makes use of FileFilter [IO-105] - Add moveDirectory() and moveFile() methods [IO-77]
- HexDump - HexDump's use of static StringBuffers isn't thread-safe [IO-136]
Enhancements from 1.3.2------------------------ FileUtils - Add a deleteQuietly method [IO-135]
- FilenameUtils - Add file name extension separator constants[IO-149]
- IOExceptionWithCause [IO-148] - Add a new IOException implementation with constructors which take a cause
- TeeInputStream [IO-129] - Add new Tee input stream implementation
- FileWriterWithEncoding [IO-153] - Add new File Writer implementation that accepts an encoding
- CharSequenceReader [IO-138] - Add new Reader implementation that handles any CharSequence (String, StringBuffer, StringBuilder or CharBuffer)
- ThesholdingOuputStream [IO-121] - Add a reset() method which sets the count of the bytes written back to zero.
- DeferredFileOutputStream [IO-130] - Add support for temporary files
- ByteArrayOutputStream - Add a new write(InputStream) method [IO-152]
- New Closed Input/Output stream implementations [IO-122] - AutoCloseInputStream - automatically closes and discards the underlying input stream - ClosedInputStream - returns -1 for any read attempts - ClosedOutputStream - throws an IOException for any write attempts - CloseShieldInputStream - prevents the underlying input stream from being closed. - CloseShieldOutputStream - prevents the underlying output stream from being closed.
- Add Singleton Constants to several stream classes [IO-143]
- PrefixFileFilter [IO-126] - Add faciltiy to specify case sensitivity on prefix matching
- SuffixFileFilter [IO-126] - Add faciltiy to specify case sensitivity on suffix matching
- RegexFileFilter [IO-74] - Add new regular expression file filter implementation
- Make IOFileFilter implementations Serializable [IO-131]
- Improve IOFileFilter toString() methods [IO-120]
- Make fields final so classes are immutable/threadsafe [IO-133] - changes to Age, Delegate, Name, Not, Prefix, Regex, Size, Suffix and Wildcard IOFileFilter implementations.
- IOCase - Add a compare method to IOCase [IO-144]
- Add a package of java.util.Comparator implementations for files [IO-145] - DefaultFileComparator - compare files using the default File.compareTo(File) method. - ExtensionFileComparator - compares files using file name extensions. - LastModifiedFileComparator - compares files using the last modified date/time. - NameFileComparator - compares files using file names. - PathFileComparator - compares files using file paths. - SizeFileComparator - compares files using file sizes. ==============================================================================Apache Commons IO Version 1.3.2==============================================================================
Compatibility with 1.3.1----------------------Binary compatible - Yes
Source compatible - Yes
Semantic compatible - Yes
Compatibility with 1.3----------------------Binary compatible - No See [IO-113]
Source compatible - No See [IO-113]
Semantic compatible - Yes
Enhancements since 1.3.1------------------------
- Created the FileCleaningTracker, basically a non-static version of the FileCleaner, which can be controlled by the user. [IO-116]- The FileCleaner is deprecated.
Bug fixes from 1.3.1--------------------
- Some tests, which are implicitly assuming a Unix-like file system, are now skipped on Windows. [IO-115]- EndianUtils - Both readSwappedUnsignedInteger(...) methods could return negative numbers due to int/long casting. [IO-117]
Bug fixes from 1.3------------------
- FileUtils - NPE in openOutputStream(File) when file has no parent in path [IO-112] - readFileToString(File) is not static [IO-113]
==============================================================================Apache Commons IO Version 1.3.1==============================================================================
Compatibility with 1.3----------------------Binary compatible - No See [IO-113]
Source compatible - No See [IO-113]
Semantic compatible - Yes
Bug fixes from 1.3------------------
- FileUtils - NPE in openOutputStream(File) when file has no parent in path [IO-112] - readFileToString(File) is not static [IO-113] ==============================================================================Apache Commons IO Version 1.3==============================================================================
Compatibility with 1.2----------------------Binary compatible - Yes
Source compatible - Yes
Semantic compatible - Yes Check the bug fixes section for semantic bug fixes
Deprecations from 1.2---------------------- WildcardFilter deprecated, replaced by WildcardFileFilter - old class only accepted files, thus had a confusing dual purpose
- FileSystemUtils.freeSpace deprecated, replaced by freeSpaceKb - freeSpace returns a result that varies by operating system and thus isn't that useful - freeSpaceKb returns much better and more consistent results - freeSpaceKb existed in v1.2, so this is a gentle cutover
Bug fixes from 1.2------------------- LineIterator now implements Iterator - It was always supposed to...
- FileSystemUtils.freeSpace/freeSpaceKb [IO-83] - These should now work on AIX and HP-UX
- FileSystemUtils.freeSpace/freeSpaceKb [IO-90] - Avoid infinite looping in Windows - Catch more errors with nice messages
- FileSystemUtils.freeSpace [IO-91] - This is now documented not to work on SunOS 5
- FileSystemUtils [IO-93] - Fixed resource leak leading to 'Too many open files' error - Previously did not destroy Process instances (as JDK Javadoc is so poor) - http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4801027
- FileUtils.touch [IO-100] - The touch method previously gave no indication when the file could not be touched successfully (such as due to access restrictions) - it now throws an IOException if the last modified date cannot be changed
- FileCleaner - This now handles the situation where an error occurs when deleting the file
- IOUtils.copy [IO-84] - Copy methods could return inaccurate byte/char count for large streams - The copy(InputStream, OutputStream) method now returns -1 if the count is greater than an int - The copy(Reader, Writer) method now throws now returns -1 if the count is greater than an int - Added a new copyLarge(InputStream, OutputStream) method that returns a long - Added a new copyLarge(Reader, Writer) method that returns a long
- CountingInputStream/CountingOutputStream [IO-84] - Methods were declared as int thus the count was innacurate for large streams - new long based methods getByteCount()/resetByteCount() added - existing methods changed to throw an exception if the count is greater than an int
- FileBasedTestCase - Fixed bug in compare content methods identified by GNU classpath
- EndianUtils.writeSwappedLong(byte[], int) [IO-101] - An int overrun in the bit shifting when it should have been a long
- EndianUtils.writeSwappedLong(InputStream) [IO-102] - The return of input.read(byte[]) was not being checked to ensure all 8 bytes were read
Enhancements from 1.2---------------------- DirectoryWalker [IO-86] - New class designed for subclassing to walk through a set of files. DirectoryWalker provides the walk of the directories, filtering of directories and files, and cancellation support. The subclass must provide the specific behaviour, such as text searching or image processing.
- IOCase - New class/enumeration for case-sensitivity control
- FilenameUtils - New methods to handle case-sensitivity - wildcardMatch - new method that has IOCase as a parameter - equals - new method that has IOCase as a parameter
- FileUtils [IO-108] - new default encoding methods for: - readFileToString(File) - readLines(File) - lineIterator(File) - writeStringToFile(File, String) - writeLines(File, Collection) - writeLines(File, Collection, String)
- FileUtils.openOutputStream [IO-107] - new method to open a FileOutputStream, creating parent directories if required- FileUtils.touch- FileUtils.copyURLToFile- FileUtils.writeStringToFile- FileUtils.writeByteArrayToFile- FileUtils.writeLines - enhanced to create parent directories if required- FileUtils.openInputStream [IO-107] - new method to open a FileInputStream, providing better error messages than the JDK
- FileUtils.isFileOlder - new methods to check if a file is older (i.e. isFileOlder()) - counterparts to the existing isFileNewer() methods.
- FileUtils.checksum, FileUtils.checksumCRC32 - new methods to create a checksum of a file
- FileUtils.copyFileToDirectory [IO-104] - new variant that optionally retains the file date
- FileDeleteStrategy- FileCleaner [IO-56,IO-70] - FileDeleteStrategy is a strategy for handling file deletion - This can be used as a calback in FileCleaner - Together these allow FileCleaner to do a forceDelete to kill directories
- FileCleaner.exitWhenFinished [IO-99] - A new method that allows the internal cleaner thread to be cleanly terminated
- WildcardFileFilter - Replacement for WildcardFilter - Accepts both files and directories - Ability to control case-sensitivity
- NameFileFilter - Ability to control case-sensitivity
- FileFileFilter - New IOFileFilter implementation - Accepts files where File.isFile() is true - In other words it filters out directories - Singleton instance provided (FILE)
- CanReadFileFilter - New IOFileFilter implementation - Accepts files where File.canRead() is true - Singleton instances provided (CAN_READ/CANNOT_READ/READ_ONLY)
- CanWriteFileFilter - New IOFileFilter implementation - Accepts files where File.canWrite() is true - Singleton instances provided (CAN_WRITE/CANNOT_WRITE)
- HiddenFileFilter - New IOFileFilter implementation - Accepts files where File.isHidden() is true - Singleton instances provided (HIDDEN/VISIBLE)
- EmptyFileFilter - New IOFileFilter implementation - Accepts files or directories that are empty - Singleton instances provided (EMPTY/NOT_EMPTY)
- TrueFileFilter/FalseFileFilter/DirectoryFileFilter - New singleton instance constants (TRUE/FALSE/DIRECTORY) - The new constants are more JDK 1.5 friendly with regards to static imports (whereas if everything uses INSTANCE, then they just clash) - The old INSTANCE constants are still present and have not been deprecated
- FileFilterUtils.sizeRangeFileFilter - new sizeRangeFileFilter(long minimumSize, long maximumSize) method which creates a filter that accepts files within the specified size range.
- FileFilterUtils.makeDirectoryOnly/makeFileOnly - two new methods that decorate a file filter to make it apply to directories only or files only
- NullWriter - New writer that acts as a sink for all data, as per /dev/null
- NullInputStream - New input stream that emulates a stream of a specified size
- NullReader - New reader that emulates a reader of a specified size
- ByteArrayOutputStream [IO-97] - Performance enhancements
==============================================================================Apache Commons IO Version 1.2==============================================================================
Compatibility with 1.1----------------------Binary compatible - Yes
Source compatible - Yes
Semantic compatible - Yes
Deprecations from 1.1---------------------
Bug fixes from 1.1------------------- FileSystemUtils.freeSpace(drive) Fix to allow Windows based command to function in French locale
- FileUtils.read* Increase certainty that files are closed in case of error
- LockableFileWriter Locking mechanism was broken and only provided limited protection [38942] File deletion and locking in case of constructor error was broken
Enhancements from 1.1---------------------- AgeFileFilter/SizeFileFilter New file filters that compares against the age and size of the file
- FileSystemUtils.freeSpaceKb(drive) New method that unifies result to be in kilobytes [38574]
- FileUtils.contentEquals(File,File) Performance improved by adding length and file location checking
- FileUtils.iterateFiles Two new method to provide direct access to iterators over files
- FileUtils.lineIterator IOUtils.lineIterator New methods to provide an iterator over the lines in a file [38083]
- FileUtils.copyDirectoryToDirectory New method to copy a directory to within another directory [36315] ==============================================================================Apache Commons IO Version 1.1==============================================================================
Incompatible changes from 1.0-----------------------------Binary compatible - Yes
Source compatible - Yes
Semantic compatible - Yes, except:- FileUtils.writeStringToFile() A null encoding previously used 'ISO-8859-1', now it uses the platform default Generally this will make no difference
- LockableFileWriter Improved validation and now create directories if necesssary
plus these bug fixes may affect you semantically:- FileUtils.touch() (Bug fix 29821) Now creates the file if it did not previously exist
- FileUtils.toFile(URL) (Bug fix 32575) Now handles escape syntax such as %20
- FileUtils.sizeOfDirectory() (Bug fix 36801) May now return a size of 0 if the directory is security restricted
Deprecations from 1.0---------------------- CopyUtils has been deprecated. Its methods have been moved to IOUtils. The new IOUtils methods handle nulls better, and have clearer names.
- IOUtils.toByteArray(String) - Use {@link String#getBytes()}- IOUtils.toString(byte[]) - Use {@link String#String(byte[])}- IOUtils.toString(byte[],String) - Use {@link String#String(byte[],String)}
Bug fixes from 1.0------------------- FileUtils - touch() [29821] Now creates the file if it did not previously exist
- FileUtils - toFile(URL) [32575] Now handles escape syntax such as %20
- FileFilterUtils - makeCVSAware(IOFileFilter) [33023] Fixed bug that caused method to be completely broken
- CountingInputStream [33336] Fixed bug that caused the count to reduce by one at the end of the stream
- CountingInputStream - skip(long) [34311] Bytes from calls to this method were not previously counted
- NullOutputStream [33481] Remove unnecessary synchronization
- AbstractFileFilter - accept(File, String) [30992] Fixed broken implementation
- FileUtils [36801] Previously threw NPE when listing files in a security restricted directory Now throw IOException with a better message
- FileUtils - writeStringToFile() Null encoding now correctly uses the platform default
Enhancements from 1.0---------------------- FilenameUtils - new class [33303,29351] A static utility class for working with filenames Seeks to ease the pain of developing on Windows and deploying on Unix
- FileSystemUtils - new class [32982,36325] A static utility class for working with file systems Provides one method at present, to get the free space on the filing system
- IOUtils - new public constants Constants for directory and line separators on Windows and Unix
- IOUtils - toByteArray(Reader,encoding) Handles encodings when reading to a byte array
- IOUtils - toCharArray(InputStream) [28979] - toCharArray(InputStream,encoding) - toCharArray(Reader) Reads a stream/reader into a charatcter array
- IOUtils - readLines(InputStream) [36214] - readLines(InputStream,encoding) - readLines(Reader) Reads a stream/reader line by line into a List of Strings
- IOUtils - toInputStream(String) [32958] - toInputStream(String,encoding) Creates an input stream that uses the string as a source of data
- IOUtils - writeLines(Collection,lineEnding,OutputStream) [36214] - writeLines(Collection,lineEnding,OutputStream,encoding) - writeLines(Collection,lineEnding,Writer) Writes a collection to a stream/writer line by line
- IOUtils - write(...) Write data to a stream/writer (moved from CopyUtils with better null handling)
- IOUtils - copy(...) Copy data between streams (moved from CopyUtils with better null handling)
- IOUtils - contentEquals(Reader,Reader) Method to compare the contents of two readers
- FileUtils - toFiles(URL[]) Converts an array of URLs to an array of Files
- FileUtils - copyDirectory() [32944] New methods to copy a directory
- FileUtils - readFileToByteArray(File) Reads an entire file into a byte array
- FileUtils - writeByteArrayToFile(File,byte[]) Writes a byte array to a file
- FileUtils - readLines(File,encoding) [36214] Reads a file line by line into a List of Strings
- FileUtils - writeLines(File,encoding,List) writeLines(File,encoding,List,lineEnding) Writes a collection to a file line by line
- FileUtils - EMPTY_FILE_ARRAY Constant for an empty array of File objects
- ConditionalFileFilter - new interface [30705] Defines the behaviour of list based filters
- AndFileFilter, OrFileFilter [30705] Now support a list of filters to and/or
- WildcardFilter [31115] New filter that can match using wildcard file names
- FileFilterUtils - makeSVNAware(IOFileFilter) New method, like makeCVSAware, that ignores Subversion source control directories
- ClassLoaderObjectInputStream An ObjectInputStream that supports a ClassLoader
- CountingInputStream,CountingOutputStream - resetCount() [28976] Adds the ability to reset the count part way through reading/writing the stream
- DeferredFileOutputStream - writeTo(OutputStream) [34173] New method to allow current contents to be written to a stream
- DeferredFileOutputStream [34142] Performance optimizations avoiding double buffering
- LockableFileWriter - encoding support [36825] Add support for character encodings to LockableFileWriter Improve the validation Create directories if necesssary
- IOUtils and EndianUtils are no longer final [28978] Allows developers to have subclasses if desired
==============================================================================Feedback==============================================================================
Open source works best when you give feedback:http://commons.apache.org/io/
Please direct all bug reports to JIRAhttp://issues.apache.org/jira/browse/IO
Or subscribe to the commons-user mailing list (prefix emails by [io])http://commons.apache.org/mail-lists.html
The Commons-IO Team123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.commons.io;
import java.io.Serializable;
/** * Byte Order Mark (BOM) representation - see {@link org.apache.commons.io.input.BOMInputStream}. * * @see org.apache.commons.io.input.BOMInputStream * @see <a href="http://en.wikipedia.org/wiki/Byte_order_mark">Wikipedia: Byte Order Mark</a> * @see <a href="http://www.w3.org/TR/2006/REC-xml-20060816/#sec-guessing">W3C: Autodetection of Character Encodings * (Non-Normative)</a> * @version $Id: ByteOrderMark.java 1586504 2014-04-10 23:34:37Z ggregory $ * @since 2.0 */public class ByteOrderMark implements Serializable {
private static final long serialVersionUID = 1L;
/** UTF-8 BOM */ public static final ByteOrderMark UTF_8 = new ByteOrderMark("UTF-8", 0xEF, 0xBB, 0xBF);
/** UTF-16BE BOM (Big-Endian) */ public static final ByteOrderMark UTF_16BE = new ByteOrderMark("UTF-16BE", 0xFE, 0xFF);
/** UTF-16LE BOM (Little-Endian) */ public static final ByteOrderMark UTF_16LE = new ByteOrderMark("UTF-16LE", 0xFF, 0xFE);
/** * UTF-32BE BOM (Big-Endian) * @since 2.2 */ public static final ByteOrderMark UTF_32BE = new ByteOrderMark("UTF-32BE", 0x00, 0x00, 0xFE, 0xFF);
/** * UTF-32LE BOM (Little-Endian) * @since 2.2 */ public static final ByteOrderMark UTF_32LE = new ByteOrderMark("UTF-32LE", 0xFF, 0xFE, 0x00, 0x00);
/** * Unicode BOM character; external form depends on the encoding. * @see <a href="http://unicode.org/faq/utf_bom.html#BOM">Byte Order Mark (BOM) FAQ</a> * @since 2.5 */ public static final char UTF_BOM = '\uFEFF';
private final String charsetName; private final int[] bytes;
/** * Construct a new BOM. * * @param charsetName The name of the charset the BOM represents * @param bytes The BOM's bytes * @throws IllegalArgumentException if the charsetName is null or * zero length * @throws IllegalArgumentException if the bytes are null or zero * length */ public ByteOrderMark(final String charsetName, final int... bytes) { if (charsetName == null || charsetName.isEmpty()) { throw new IllegalArgumentException("No charsetName specified"); } if (bytes == null || bytes.length == 0) { throw new IllegalArgumentException("No bytes specified"); } this.charsetName = charsetName; this.bytes = new int[bytes.length]; System.arraycopy(bytes, 0, this.bytes, 0, bytes.length); }
/** * Return the name of the {@link java.nio.charset.Charset} the BOM represents. * * @return the character set name */ public String getCharsetName() { return charsetName; }
/** * Return the length of the BOM's bytes. * * @return the length of the BOM's bytes */ public int length() { return bytes.length; }
/** * The byte at the specified position. * * @param pos The position * @return The specified byte */ public int get(final int pos) { return bytes[pos]; }
/** * Return a copy of the BOM's bytes. * * @return a copy of the BOM's bytes */ public byte[] getBytes() { final byte[] copy = new byte[bytes.length]; for (int i = 0; i < bytes.length; i++) { copy[i] = (byte)bytes[i]; } return copy; }
/** * Indicates if this BOM's bytes equals another. * * @param obj The object to compare to * @return true if the bom's bytes are equal, otherwise * false */ @Override public boolean equals(final Object obj) { if (!(obj instanceof ByteOrderMark)) { return false; } final ByteOrderMark bom = (ByteOrderMark)obj; if (bytes.length != bom.length()) { return false; } for (int i = 0; i < bytes.length; i++) { if (bytes[i] != bom.get(i)) { return false; } } return true; }
/** * Return the hashcode for this BOM. * * @return the hashcode for this BOM. * @see java.lang.Object#hashCode() */ @Override public int hashCode() { int hashCode = getClass().hashCode(); for (final int b : bytes) { hashCode += b; } return hashCode; }
/** * Provide a String representation of the BOM. * * @return the length of the BOM's bytes */ @Override public String toString() { final StringBuilder builder = new StringBuilder(); builder.append(getClass().getSimpleName()); builder.append('['); builder.append(charsetName); builder.append(": "); for (int i = 0; i < bytes.length; i++) { if (i > 0) { builder.append(","); } builder.append("0x"); builder.append(Integer.toHexString(0xFF & bytes[i]).toUpperCase()); } builder.append(']'); return builder.toString(); }
}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.io;
import java.nio.charset.Charset;
import java.util.Collections;
import java.util.SortedMap;
import java.util.TreeMap;
/**
* Charsets required of every implementation of the Java platform.
*
* From the Java documentation <a href="http://docs.oracle.com/javase/6/docs/api/java/nio/charset/Charset.html">
* Standard charsets</a>:
* <p>
* <cite>Every implementation of the Java platform is required to support the following character encodings. Consult
* the release documentation for your implementation to see if any other encodings are supported. Consult the release
* documentation for your implementation to see if any other encodings are supported. </cite>
* </p>
*
* <ul>
* <li><code>US-ASCII</code><br>
* Seven-bit ASCII, a.k.a. ISO646-US, a.k.a. the Basic Latin block of the Unicode character set.</li>
* <li><code>ISO-8859-1</code><br>
* ISO Latin Alphabet No. 1, a.k.a. ISO-LATIN-1.</li>
* <li><code>UTF-8</code><br>
* Eight-bit Unicode Transformation Format.</li>
* <li><code>UTF-16BE</code><br>
* Sixteen-bit Unicode Transformation Format, big-endian byte order.</li>
* <li><code>UTF-16LE</code><br>
* Sixteen-bit Unicode Transformation Format, little-endian byte order.</li>
* <li><code>UTF-16</code><br>
* Sixteen-bit Unicode Transformation Format, byte order specified by a mandatory initial byte-order mark (either order
* accepted on input, big-endian used on output.)</li>
* </ul>
*
* @see <a href="http://docs.oracle.com/javase/6/docs/api/java/nio/charset/Charset.html">Standard charsets</a>
* @since 2.3
* @version $Id: Charsets.java 1686747 2015-06-21 18:44:49Z krosenvold $
*/
public class Charsets {
//
// This class should only contain Charset instances for required encodings. This guarantees that it will load
// correctly and without delay on all Java platforms.
//
/**
* Constructs a sorted map from canonical charset names to charset objects required of every implementation of the
* Java platform.
* <p>
* From the Java documentation <a href="http://docs.oracle.com/javase/6/docs/api/java/nio/charset/Charset.html">
* Standard charsets</a>:
* </p>
*
* @return An immutable, case-insensitive map from canonical charset names to charset objects.
* @see Charset#availableCharsets()
* @since 2.5
*/
public static SortedMap<String, Charset> requiredCharsets() {
// maybe cache?
// TODO Re-implement on Java 7 to use java.nio.charset.StandardCharsets
final TreeMap<String, Charset> m = new TreeMap<String, Charset>(String.CASE_INSENSITIVE_ORDER);
m.put(ISO_8859_1.name(), ISO_8859_1);
m.put(US_ASCII.name(), US_ASCII);
m.put(UTF_16.name(), UTF_16);
m.put(UTF_16BE.name(), UTF_16BE);
m.put(UTF_16LE.name(), UTF_16LE);
m.put(UTF_8.name(), UTF_8);
return Collections.unmodifiableSortedMap(m);
}
/**
* Returns the given Charset or the default Charset if the given Charset is null.
*
* @param charset
* A charset or null.
* @return the given Charset or the default Charset if the given Charset is null
*/
public static Charset toCharset(final Charset charset) {
return charset == null ? Charset.defaultCharset() : charset;
}
/**
* Returns a Charset for the named charset. If the name is null, return the default Charset.
*
* @param charset
* The name of the requested charset, may be null.
* @return a Charset for the named charset
* @throws java.nio.charset.UnsupportedCharsetException
* If the named charset is unavailable
*/
public static Charset toCharset(final String charset) {
return charset == null ? Charset.defaultCharset() : Charset.forName(charset);
}
/**
* CharEncodingISO Latin Alphabet No. 1, a.k.a. ISO-LATIN-1.
* <p>
* Every implementation of the Java platform is required to support this character encoding.
* </p>
*
* @see <a href="http://docs.oracle.com/javase/6/docs/api/java/nio/charset/Charset.html">Standard charsets</a>
* @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets}
*/
@Deprecated
public static final Charset ISO_8859_1 = Charset.forName("ISO-8859-1");
/**
* <p>
* Seven-bit ASCII, also known as ISO646-US, also known as the Basic Latin block of the Unicode character set.
* </p>
* <p>
* Every implementation of the Java platform is required to support this character encoding.
* </p>
*
* @see <a href="http://docs.oracle.com/javase/6/docs/api/java/nio/charset/Charset.html">Standard charsets</a>
* @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets}
*/
@Deprecated
public static final Charset US_ASCII = Charset.forName("US-ASCII");
/**
* <p>
* Sixteen-bit Unicode Transformation Format, The byte order specified by a mandatory initial byte-order mark
* (either order accepted on input, big-endian used on output)
* </p>
* <p>
* Every implementation of the Java platform is required to support this character encoding.
* </p>
*
* @see <a href="http://docs.oracle.com/javase/6/docs/api/java/nio/charset/Charset.html">Standard charsets</a>
* @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets}
*/
@Deprecated
public static final Charset UTF_16 = Charset.forName("UTF-16");
/**
* <p>
* Sixteen-bit Unicode Transformation Format, big-endian byte order.
* </p>
* <p>
* Every implementation of the Java platform is required to support this character encoding.
* </p>
*
* @see <a href="http://docs.oracle.com/javase/6/docs/api/java/nio/charset/Charset.html">Standard charsets</a>
* @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets}
*/
@Deprecated
public static final Charset UTF_16BE = Charset.forName("UTF-16BE");
/**
* <p>
* Sixteen-bit Unicode Transformation Format, little-endian byte order.
* </p>
* <p>
* Every implementation of the Java platform is required to support this character encoding.
* </p>
*
* @see <a href="http://docs.oracle.com/javase/6/docs/api/java/nio/charset/Charset.html">Standard charsets</a>
* @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets}
*/
@Deprecated
public static final Charset UTF_16LE = Charset.forName("UTF-16LE");
/**
* <p>
* Eight-bit Unicode Transformation Format.
* </p>
* <p>
* Every implementation of the Java platform is required to support this character encoding.
* </p>
*
* @see <a href="http://docs.oracle.com/javase/6/docs/api/java/nio/charset/Charset.html">Standard charsets</a>
* @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets}
*/
@Deprecated
public static final Charset UTF_8 = Charset.forName("UTF-8");
}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.commons.io;
import java.io.ByteArrayInputStream;import java.io.IOException;import java.io.InputStream;import java.io.InputStreamReader;import java.io.OutputStream;import java.io.OutputStreamWriter;import java.io.Reader;import java.io.StringReader;import java.io.Writer;import java.nio.charset.Charset;
/** * This class provides static utility methods for buffered * copying between sources (<code>InputStream</code>, <code>Reader</code>, * <code>String</code> and <code>byte[]</code>) and destinations * (<code>OutputStream</code>, <code>Writer</code>, <code>String</code> and * <code>byte[]</code>). * <p> * Unless otherwise noted, these <code>copy</code> methods do <em>not</em> * flush or close the streams. Often doing so would require making non-portable * assumptions about the streams' origin and further use. This means that both * streams' <code>close()</code> methods must be called after copying. if one * omits this step, then the stream resources (sockets, file descriptors) are * released when the associated Stream is garbage-collected. It is not a good * idea to rely on this mechanism. For a good overview of the distinction * between "memory management" and "resource management", see * <a href="http://www.unixreview.com/articles/1998/9804/9804ja/ja.htm">this * UnixReview article</a>. * <p> * For byte-to-char methods, a <code>copy</code> variant allows the encoding * to be selected (otherwise the platform default is used). We would like to * encourage you to always specify the encoding because relying on the platform * default can lead to unexpected results. * <p> * We don't provide special variants for the <code>copy</code> methods that * let you specify the buffer size because in modern VMs the impact on speed * seems to be minimal. We're using a default buffer size of 4 KB. * <p> * The <code>copy</code> methods use an internal buffer when copying. It is * therefore advisable <em>not</em> to deliberately wrap the stream arguments * to the <code>copy</code> methods in <code>Buffered*</code> streams. For * example, don't do the following: * <pre> * copy( new BufferedInputStream( in ), new BufferedOutputStream( out ) ); * </pre> * The rationale is as follows: * <p> * Imagine that an InputStream's read() is a very expensive operation, which * would usually suggest wrapping in a BufferedInputStream. The * BufferedInputStream works by issuing infrequent * {@link java.io.InputStream#read(byte[] b, int off, int len)} requests on the * underlying InputStream, to fill an internal buffer, from which further * <code>read</code> requests can inexpensively get their data (until the buffer * runs out). * <p> * However, the <code>copy</code> methods do the same thing, keeping an * internal buffer, populated by * {@link InputStream#read(byte[] b, int off, int len)} requests. Having two * buffers (or three if the destination stream is also buffered) is pointless, * and the unnecessary buffer management hurts performance slightly (about 3%, * according to some simple experiments). * <p> * Behold, intrepid explorers; a map of this class: * <pre> * Method Input Output Dependency * ------ ----- ------ ------- * 1 copy InputStream OutputStream (primitive) * 2 copy Reader Writer (primitive) * * 3 copy InputStream Writer 2 * * 4 copy Reader OutputStream 2 * * 5 copy String OutputStream 2 * 6 copy String Writer (trivial) * * 7 copy byte[] Writer 3 * 8 copy byte[] OutputStream (trivial) * </pre> * <p> * Note that only the first two methods shuffle bytes; the rest use these * two, or (if possible) copy using native Java copy methods. As there are * method variants to specify the encoding, each row may * correspond to up to 2 methods. * <p> * Origin of code: Excalibur. * * @version $Id: CopyUtils.java 1680650 2015-05-20 18:36:40Z britter $ * @deprecated Use IOUtils. Will be removed in 2.0. * Methods renamed to IOUtils.write() or IOUtils.copy(). * Null handling behaviour changed in IOUtils (null data does not * throw NullPointerException). */@Deprecatedpublic class CopyUtils {
/** * The default size of the buffer. */ private static final int DEFAULT_BUFFER_SIZE = 1024 * 4;
/** * Instances should NOT be constructed in standard programming. */ public CopyUtils() { }
// ---------------------------------------------------------------- // byte[] -> OutputStream // ----------------------------------------------------------------
/** * Copy bytes from a <code>byte[]</code> to an <code>OutputStream</code>. * @param input the byte array to read from * @param output the <code>OutputStream</code> to write to * @throws IOException In case of an I/O problem */ public static void copy(final byte[] input, final OutputStream output) throws IOException { output.write(input); }
// ---------------------------------------------------------------- // byte[] -> Writer // ----------------------------------------------------------------
/** * Copy and convert bytes from a <code>byte[]</code> to chars on a * <code>Writer</code>. * The platform's default encoding is used for the byte-to-char conversion. * @param input the byte array to read from * @param output the <code>Writer</code> to write to * @throws IOException In case of an I/O problem * @deprecated 2.5 use {@link #copy(byte[], Writer, String)} instead */ @Deprecated public static void copy(final byte[] input, final Writer output) throws IOException { final ByteArrayInputStream in = new ByteArrayInputStream(input); copy(in, output); }
/** * Copy and convert bytes from a <code>byte[]</code> to chars on a * <code>Writer</code>, using the specified encoding. * @param input the byte array to read from * @param output the <code>Writer</code> to write to * @param encoding The name of a supported character encoding. See the * <a href="http://www.iana.org/assignments/character-sets">IANA * Charset Registry</a> for a list of valid encoding types. * @throws IOException In case of an I/O problem */ public static void copy( final byte[] input, final Writer output, final String encoding) throws IOException { final ByteArrayInputStream in = new ByteArrayInputStream(input); copy(in, output, encoding); }
// ---------------------------------------------------------------- // Core copy methods // ----------------------------------------------------------------
/** * Copy bytes from an <code>InputStream</code> to an * <code>OutputStream</code>. * @param input the <code>InputStream</code> to read from * @param output the <code>OutputStream</code> to write to * @return the number of bytes copied * @throws IOException In case of an I/O problem */ public static int copy( final InputStream input, final OutputStream output) throws IOException { final byte[] buffer = new byte[DEFAULT_BUFFER_SIZE]; int count = 0; int n = 0; while (-1 != (n = input.read(buffer))) { output.write(buffer, 0, n); count += n; } return count; }
// ---------------------------------------------------------------- // Reader -> Writer // ----------------------------------------------------------------
/** * Copy chars from a <code>Reader</code> to a <code>Writer</code>. * @param input the <code>Reader</code> to read from * @param output the <code>Writer</code> to write to * @return the number of characters copied * @throws IOException In case of an I/O problem */ public static int copy( final Reader input, final Writer output) throws IOException { final char[] buffer = new char[DEFAULT_BUFFER_SIZE]; int count = 0; int n = 0; while (-1 != (n = input.read(buffer))) { output.write(buffer, 0, n); count += n; } return count; }
// ---------------------------------------------------------------- // InputStream -> Writer // ----------------------------------------------------------------
/** * Copy and convert bytes from an <code>InputStream</code> to chars on a * <code>Writer</code>. * The platform's default encoding is used for the byte-to-char conversion. * @param input the <code>InputStream</code> to read from * @param output the <code>Writer</code> to write to * @throws IOException In case of an I/O problem * @deprecated 2.5 use {@link #copy(InputStream, Writer, String)} instead */ @Deprecated public static void copy( final InputStream input, final Writer output) throws IOException { // make explicit the dependency on the default encoding final InputStreamReader in = new InputStreamReader(input, Charset.defaultCharset()); copy(in, output); }
/** * Copy and convert bytes from an <code>InputStream</code> to chars on a * <code>Writer</code>, using the specified encoding. * @param input the <code>InputStream</code> to read from * @param output the <code>Writer</code> to write to * @param encoding The name of a supported character encoding. See the * <a href="http://www.iana.org/assignments/character-sets">IANA * Charset Registry</a> for a list of valid encoding types. * @throws IOException In case of an I/O problem */ public static void copy( final InputStream input, final Writer output, final String encoding) throws IOException { final InputStreamReader in = new InputStreamReader(input, encoding); copy(in, output); }
// ---------------------------------------------------------------- // Reader -> OutputStream // ----------------------------------------------------------------
/** * Serialize chars from a <code>Reader</code> to bytes on an * <code>OutputStream</code>, and flush the <code>OutputStream</code>. * Uses the default platform encoding. * @param input the <code>Reader</code> to read from * @param output the <code>OutputStream</code> to write to * @throws IOException In case of an I/O problem * @deprecated 2.5 use {@link #copy(Reader, OutputStream, String)} instead */ @Deprecated public static void copy( final Reader input, final OutputStream output) throws IOException { // make explicit the dependency on the default encoding final OutputStreamWriter out = new OutputStreamWriter(output, Charset.defaultCharset()); copy(input, out); // XXX Unless anyone is planning on rewriting OutputStreamWriter, we // have to flush here. out.flush(); }
/** * Serialize chars from a <code>Reader</code> to bytes on an * <code>OutputStream</code>, and flush the <code>OutputStream</code>. * @param input the <code>Reader</code> to read from * @param output the <code>OutputStream</code> to write to * @param encoding The name of a supported character encoding. See the * <a href="http://www.iana.org/assignments/character-sets">IANA * Charset Registry</a> for a list of valid encoding types. * @throws IOException In case of an I/O problem * @since 2.5 */ public static void copy( final Reader input, final OutputStream output, final String encoding) throws IOException { final OutputStreamWriter out = new OutputStreamWriter(output, encoding); copy(input, out); // XXX Unless anyone is planning on rewriting OutputStreamWriter, we // have to flush here. out.flush(); }
// ---------------------------------------------------------------- // String -> OutputStream // ----------------------------------------------------------------
/** * Serialize chars from a <code>String</code> to bytes on an * <code>OutputStream</code>, and * flush the <code>OutputStream</code>. * Uses the platform default encoding. * @param input the <code>String</code> to read from * @param output the <code>OutputStream</code> to write to * @throws IOException In case of an I/O problem * @deprecated 2.5 use {@link #copy(String, OutputStream, String)} instead */ @Deprecated public static void copy( final String input, final OutputStream output) throws IOException { final StringReader in = new StringReader(input); // make explicit the dependency on the default encoding final OutputStreamWriter out = new OutputStreamWriter(output, Charset.defaultCharset()); copy(in, out); // XXX Unless anyone is planning on rewriting OutputStreamWriter, we // have to flush here. out.flush(); }
/** * Serialize chars from a <code>String</code> to bytes on an * <code>OutputStream</code>, and * flush the <code>OutputStream</code>. * @param input the <code>String</code> to read from * @param output the <code>OutputStream</code> to write to * @param encoding The name of a supported character encoding. See the * <a href="http://www.iana.org/assignments/character-sets">IANA * Charset Registry</a> for a list of valid encoding types. * @throws IOException In case of an I/O problem * @since 2.5 */ public static void copy( final String input, final OutputStream output, final String encoding) throws IOException { final StringReader in = new StringReader(input); final OutputStreamWriter out = new OutputStreamWriter(output, encoding); copy(in, out); // XXX Unless anyone is planning on rewriting OutputStreamWriter, we // have to flush here. out.flush(); }
// ---------------------------------------------------------------- // String -> Writer // ----------------------------------------------------------------
/** * Copy chars from a <code>String</code> to a <code>Writer</code>. * @param input the <code>String</code> to read from * @param output the <code>Writer</code> to write to * @throws IOException In case of an I/O problem */ public static void copy(final String input, final Writer output) throws IOException { output.write(input); }
}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.commons.io;
import java.io.File;import java.io.FileFilter;import java.io.IOException;import java.util.Collection;
import org.apache.commons.io.filefilter.FileFilterUtils;import org.apache.commons.io.filefilter.IOFileFilter;import org.apache.commons.io.filefilter.TrueFileFilter;
/** * Abstract class that walks through a directory hierarchy and provides * subclasses with convenient hooks to add specific behaviour. * <p> * This class operates with a {@link FileFilter} and maximum depth to * limit the files and direcories visited. * Commons IO supplies many common filter implementations in the * <a href="filefilter/package-summary.html"> filefilter</a> package. * <p> * The following sections describe: * <ul> * <li><a href="#example">1. Example Implementation</a> - example * <code>FileCleaner</code> implementation.</li> * <li><a href="#filter">2. Filter Example</a> - using * {@link FileFilter}(s) with <code>DirectoryWalker</code>.</li> * <li><a href="#cancel">3. Cancellation</a> - how to implement cancellation * behaviour.</li> * </ul> * * <a name="example"></a> * <h3>1. Example Implementation</h3> * * There are many possible extensions, for example, to delete all * files and '.svn' directories, and return a list of deleted files: * <pre> * public class FileCleaner extends DirectoryWalker { * * public FileCleaner() { * super(); * } * * public List clean(File startDirectory) { * List results = new ArrayList(); * walk(startDirectory, results); * return results; * } * * protected boolean handleDirectory(File directory, int depth, Collection results) { * // delete svn directories and then skip * if (".svn".equals(directory.getName())) { * directory.delete(); * return false; * } else { * return true; * } * * } * * protected void handleFile(File file, int depth, Collection results) { * // delete file and add to list of deleted * file.delete(); * results.add(file); * } * } * </pre> * * <a name="filter"></a> * <h3>2. Filter Example</h3> * * Choosing which directories and files to process can be a key aspect * of using this class. This information can be setup in three ways, * via three different constructors. * <p> * The first option is to visit all directories and files. * This is achieved via the no-args constructor. * <p> * The second constructor option is to supply a single {@link FileFilter} * that describes the files and directories to visit. Care must be taken * with this option as the same filter is used for both directories * and files. * <p> * For example, if you wanted all directories which are not hidden * and files which end in ".txt": * <pre> * public class FooDirectoryWalker extends DirectoryWalker { * public FooDirectoryWalker(FileFilter filter) { * super(filter, -1); * } * } * * // Build up the filters and create the walker * // Create a filter for Non-hidden directories * IOFileFilter fooDirFilter = * FileFilterUtils.andFileFilter(FileFilterUtils.directoryFileFilter, * HiddenFileFilter.VISIBLE); * * // Create a filter for Files ending in ".txt" * IOFileFilter fooFileFilter = * FileFilterUtils.andFileFilter(FileFilterUtils.fileFileFilter, * FileFilterUtils.suffixFileFilter(".txt")); * * // Combine the directory and file filters using an OR condition * java.io.FileFilter fooFilter = * FileFilterUtils.orFileFilter(fooDirFilter, fooFileFilter); * * // Use the filter to construct a DirectoryWalker implementation * FooDirectoryWalker walker = new FooDirectoryWalker(fooFilter); * </pre> * <p> * The third constructor option is to specify separate filters, one for * directories and one for files. These are combined internally to form * the correct <code>FileFilter</code>, something which is very easy to * get wrong when attempted manually, particularly when trying to * express constructs like 'any file in directories named docs'. * <p> * For example, if you wanted all directories which are not hidden * and files which end in ".txt": * <pre> * public class FooDirectoryWalker extends DirectoryWalker { * public FooDirectoryWalker(IOFileFilter dirFilter, IOFileFilter fileFilter) { * super(dirFilter, fileFilter, -1); * } * } * * // Use the filters to construct the walker * FooDirectoryWalker walker = new FooDirectoryWalker( * HiddenFileFilter.VISIBLE, * FileFilterUtils.suffixFileFilter(".txt"), * ); * </pre> * This is much simpler than the previous example, and is why it is the preferred * option for filtering. * * <a name="cancel"></a> * <h3>3. Cancellation</h3> * * The DirectoryWalker contains some of the logic required for cancel processing. * Subclasses must complete the implementation. * <p> * What <code>DirectoryWalker</code> does provide for cancellation is: * <ul> * <li>{@link CancelException} which can be thrown in any of the * <i>lifecycle</i> methods to stop processing.</li> * <li>The <code>walk()</code> method traps thrown {@link CancelException} * and calls the <code>handleCancelled()</code> method, providing * a place for custom cancel processing.</li> * </ul> * <p> * Implementations need to provide: * <ul> * <li>The decision logic on whether to cancel processing or not.</li> * <li>Constructing and throwing a {@link CancelException}.</li> * <li>Custom cancel processing in the <code>handleCancelled()</code> method. * </ul> * <p> * Two possible scenarios are envisaged for cancellation: * <ul> * <li><a href="#external">3.1 External / Mult-threaded</a> - cancellation being * decided/initiated by an external process.</li> * <li><a href="#internal">3.2 Internal</a> - cancellation being decided/initiated * from within a DirectoryWalker implementation.</li> * </ul> * <p> * The following sections provide example implementations for these two different * scenarios. * * <a name="external"></a> * <h4>3.1 External / Multi-threaded</h4> * * This example provides a public <code>cancel()</code> method that can be * called by another thread to stop the processing. A typical example use-case * would be a cancel button on a GUI. Calling this method sets a * <a href="http://java.sun.com/docs/books/jls/second_edition/html/classes.doc.html#36930"> * volatile</a> flag to ensure it will work properly in a multi-threaded environment. * The flag is returned by the <code>handleIsCancelled()</code> method, which * will cause the walk to stop immediately. The <code>handleCancelled()</code> * method will be the next, and last, callback method received once cancellation * has occurred. * * <pre> * public class FooDirectoryWalker extends DirectoryWalker { * * private volatile boolean cancelled = false; * * public void cancel() { * cancelled = true; * } * * protected boolean handleIsCancelled(File file, int depth, Collection results) { * return cancelled; * } * * protected void handleCancelled(File startDirectory, Collection results, CancelException cancel) { * // implement processing required when a cancellation occurs * } * } * </pre> * * <a name="internal"></a> * <h4>3.2 Internal</h4> * * This shows an example of how internal cancellation processing could be implemented. * <b>Note</b> the decision logic and throwing a {@link CancelException} could be implemented * in any of the <i>lifecycle</i> methods. * * <pre> * public class BarDirectoryWalker extends DirectoryWalker { * * protected boolean handleDirectory(File directory, int depth, Collection results) throws IOException { * // cancel if hidden directory * if (directory.isHidden()) { * throw new CancelException(file, depth); * } * return true; * } * * protected void handleFile(File file, int depth, Collection results) throws IOException { * // cancel if read-only file * if (!file.canWrite()) { * throw new CancelException(file, depth); * } * results.add(file); * } * * protected void handleCancelled(File startDirectory, Collection results, CancelException cancel) { * // implement processing required when a cancellation occurs * } * } * </pre> * * @since 1.3 * @version $Id: DirectoryWalker.java 1723627 2016-01-07 21:15:47Z niallp $ */public abstract class DirectoryWalker<T> {
/** * The file filter to use to filter files and directories. */ private final FileFilter filter; /** * The limit on the directory depth to walk. */ private final int depthLimit;
/** * Construct an instance with no filtering and unlimited <i>depth</i>. */ protected DirectoryWalker() { this(null, -1); }
/** * Construct an instance with a filter and limit the <i>depth</i> navigated to. * <p> * The filter controls which files and directories will be navigated to as * part of the walk. The {@link FileFilterUtils} class is useful for combining * various filters together. A {@code null} filter means that no * filtering should occur and all files and directories will be visited. * * @param filter the filter to apply, null means visit all files * @param depthLimit controls how <i>deep</i> the hierarchy is * navigated to (less than 0 means unlimited) */ protected DirectoryWalker(final FileFilter filter, final int depthLimit) { this.filter = filter; this.depthLimit = depthLimit; }
/** * Construct an instance with a directory and a file filter and an optional * limit on the <i>depth</i> navigated to. * <p> * The filters control which files and directories will be navigated to as part * of the walk. This constructor uses {@link FileFilterUtils#makeDirectoryOnly(IOFileFilter)} * and {@link FileFilterUtils#makeFileOnly(IOFileFilter)} internally to combine the filters. * A {@code null} filter means that no filtering should occur. * * @param directoryFilter the filter to apply to directories, null means visit all directories * @param fileFilter the filter to apply to files, null means visit all files * @param depthLimit controls how <i>deep</i> the hierarchy is * navigated to (less than 0 means unlimited) */ protected DirectoryWalker(IOFileFilter directoryFilter, IOFileFilter fileFilter, final int depthLimit) { if (directoryFilter == null && fileFilter == null) { this.filter = null; } else { directoryFilter = directoryFilter != null ? directoryFilter : TrueFileFilter.TRUE; fileFilter = fileFilter != null ? fileFilter : TrueFileFilter.TRUE; directoryFilter = FileFilterUtils.makeDirectoryOnly(directoryFilter); fileFilter = FileFilterUtils.makeFileOnly(fileFilter); this.filter = FileFilterUtils.or(directoryFilter, fileFilter); } this.depthLimit = depthLimit; }
//----------------------------------------------------------------------- /** * Internal method that walks the directory hierarchy in a depth-first manner. * <p> * Users of this class do not need to call this method. This method will * be called automatically by another (public) method on the specific subclass. * <p> * Writers of subclasses should call this method to start the directory walk. * Once called, this method will emit events as it walks the hierarchy. * The event methods have the prefix <code>handle</code>. * * @param startDirectory the directory to start from, not null * @param results the collection of result objects, may be updated * @throws NullPointerException if the start directory is null * @throws IOException if an I/O Error occurs */ protected final void walk(final File startDirectory, final Collection<T> results) throws IOException { if (startDirectory == null) { throw new NullPointerException("Start Directory is null"); } try { handleStart(startDirectory, results); walk(startDirectory, 0, results); handleEnd(results); } catch(final CancelException cancel) { handleCancelled(startDirectory, results, cancel); } }
/** * Main recursive method to examine the directory hierarchy. * * @param directory the directory to examine, not null * @param depth the directory level (starting directory = 0) * @param results the collection of result objects, may be updated * @throws IOException if an I/O Error occurs */ private void walk(final File directory, final int depth, final Collection<T> results) throws IOException { checkIfCancelled(directory, depth, results); if (handleDirectory(directory, depth, results)) { handleDirectoryStart(directory, depth, results); final int childDepth = depth + 1; if (depthLimit < 0 || childDepth <= depthLimit) { checkIfCancelled(directory, depth, results); File[] childFiles = filter == null ? directory.listFiles() : directory.listFiles(filter); childFiles = filterDirectoryContents(directory, depth, childFiles); if (childFiles == null) { handleRestricted(directory, childDepth, results); } else { for (final File childFile : childFiles) { if (childFile.isDirectory()) { walk(childFile, childDepth, results); } else { checkIfCancelled(childFile, childDepth, results); handleFile(childFile, childDepth, results); checkIfCancelled(childFile, childDepth, results); } } } } handleDirectoryEnd(directory, depth, results); } checkIfCancelled(directory, depth, results); }
//----------------------------------------------------------------------- /** * Checks whether the walk has been cancelled by calling {@link #handleIsCancelled}, * throwing a <code>CancelException</code> if it has. * <p> * Writers of subclasses should not normally call this method as it is called * automatically by the walk of the tree. However, sometimes a single method, * typically {@link #handleFile}, may take a long time to run. In that case, * you may wish to check for cancellation by calling this method. * * @param file the current file being processed * @param depth the current file level (starting directory = 0) * @param results the collection of result objects, may be updated * @throws IOException if an I/O Error occurs */ protected final void checkIfCancelled(final File file, final int depth, final Collection<T> results) throws IOException { if (handleIsCancelled(file, depth, results)) { throw new CancelException(file, depth); } }
/** * Overridable callback method invoked to determine if the entire walk * operation should be immediately cancelled. * <p> * This method should be implemented by those subclasses that want to * provide a public <code>cancel()</code> method available from another * thread. The design pattern for the subclass should be as follows: * <pre> * public class FooDirectoryWalker extends DirectoryWalker { * private volatile boolean cancelled = false; * * public void cancel() { * cancelled = true; * } * private void handleIsCancelled(File file, int depth, Collection results) { * return cancelled; * } * protected void handleCancelled(File startDirectory, * Collection results, CancelException cancel) { * // implement processing required when a cancellation occurs * } * } * </pre> * <p> * If this method returns true, then the directory walk is immediately * cancelled. The next callback method will be {@link #handleCancelled}. * <p> * This implementation returns false. * * @param file the file or directory being processed * @param depth the current directory level (starting directory = 0) * @param results the collection of result objects, may be updated * @return true if the walk has been cancelled * @throws IOException if an I/O Error occurs */ protected boolean handleIsCancelled( final File file, final int depth, final Collection<T> results) throws IOException { // do nothing - overridable by subclass return false; // not cancelled }
/** * Overridable callback method invoked when the operation is cancelled. * The file being processed when the cancellation occurred can be * obtained from the exception. * <p> * This implementation just re-throws the {@link CancelException}. * * @param startDirectory the directory that the walk started from * @param results the collection of result objects, may be updated * @param cancel the exception throw to cancel further processing * containing details at the point of cancellation. * @throws IOException if an I/O Error occurs */ protected void handleCancelled(final File startDirectory, final Collection<T> results, final CancelException cancel) throws IOException { // re-throw exception - overridable by subclass throw cancel; }
//----------------------------------------------------------------------- /** * Overridable callback method invoked at the start of processing. * <p> * This implementation does nothing. * * @param startDirectory the directory to start from * @param results the collection of result objects, may be updated * @throws IOException if an I/O Error occurs */ protected void handleStart(final File startDirectory, final Collection<T> results) throws IOException { // do nothing - overridable by subclass }
/** * Overridable callback method invoked to determine if a directory should be processed. * <p> * This method returns a boolean to indicate if the directory should be examined or not. * If you return false, the entire directory and any subdirectories will be skipped. * Note that this functionality is in addition to the filtering by file filter. * <p> * This implementation does nothing and returns true. * * @param directory the current directory being processed * @param depth the current directory level (starting directory = 0) * @param results the collection of result objects, may be updated * @return true to process this directory, false to skip this directory * @throws IOException if an I/O Error occurs */ protected boolean handleDirectory(final File directory, final int depth, final Collection<T> results) throws IOException { // do nothing - overridable by subclass return true; // process directory }
/** * Overridable callback method invoked at the start of processing each directory. * <p> * This implementation does nothing. * * @param directory the current directory being processed * @param depth the current directory level (starting directory = 0) * @param results the collection of result objects, may be updated * @throws IOException if an I/O Error occurs */ protected void handleDirectoryStart(final File directory, final int depth, final Collection<T> results) throws IOException { // do nothing - overridable by subclass }
/** * Overridable callback method invoked with the contents of each directory. * <p> * This implementation returns the files unchanged * * @param directory the current directory being processed * @param depth the current directory level (starting directory = 0) * @param files the files (possibly filtered) in the directory, may be {@code null} * @return the filtered list of files * @throws IOException if an I/O Error occurs * @since 2.0 */ protected File[] filterDirectoryContents(final File directory, final int depth, final File[] files) throws IOException { return files; }
/** * Overridable callback method invoked for each (non-directory) file. * <p> * This implementation does nothing. * * @param file the current file being processed * @param depth the current directory level (starting directory = 0) * @param results the collection of result objects, may be updated * @throws IOException if an I/O Error occurs */ protected void handleFile(final File file, final int depth, final Collection<T> results) throws IOException { // do nothing - overridable by subclass }
/** * Overridable callback method invoked for each restricted directory. * <p> * This implementation does nothing. * * @param directory the restricted directory * @param depth the current directory level (starting directory = 0) * @param results the collection of result objects, may be updated * @throws IOException if an I/O Error occurs */ protected void handleRestricted(final File directory, final int depth, final Collection<T> results) throws IOException { // do nothing - overridable by subclass }
/** * Overridable callback method invoked at the end of processing each directory. * <p> * This implementation does nothing. * * @param directory the directory being processed * @param depth the current directory level (starting directory = 0) * @param results the collection of result objects, may be updated * @throws IOException if an I/O Error occurs */ protected void handleDirectoryEnd(final File directory, final int depth, final Collection<T> results) throws IOException { // do nothing - overridable by subclass }
/** * Overridable callback method invoked at the end of processing. * <p> * This implementation does nothing. * * @param results the collection of result objects, may be updated * @throws IOException if an I/O Error occurs */ protected void handleEnd(final Collection<T> results) throws IOException { // do nothing - overridable by subclass }
//----------------------------------------------------------------------- /** * CancelException is thrown in DirectoryWalker to cancel the current * processing. */ public static class CancelException extends IOException {
/** Serialization id. */ private static final long serialVersionUID = 1347339620135041008L;
/** The file being processed when the exception was thrown. */ private final File file; /** The file depth when the exception was thrown. */ private final int depth;
/** * Constructs a <code>CancelException</code> with * the file and depth when cancellation occurred. * * @param file the file when the operation was cancelled, may be null * @param depth the depth when the operation was cancelled, may be null */ public CancelException(final File file, final int depth) { this("Operation Cancelled", file, depth); }
/** * Constructs a <code>CancelException</code> with * an appropriate message and the file and depth when * cancellation occurred. * * @param message the detail message * @param file the file when the operation was cancelled * @param depth the depth when the operation was cancelled */ public CancelException(final String message, final File file, final int depth) { super(message); this.file = file; this.depth = depth; }
/** * Return the file when the operation was cancelled. * * @return the file when the operation was cancelled */ public File getFile() { return file; }
/** * Return the depth when the operation was cancelled. * * @return the depth when the operation was cancelled */ public int getDepth() { return depth; } }}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.commons.io;
import static org.apache.commons.io.IOUtils.EOF;
import java.io.EOFException;import java.io.IOException;import java.io.InputStream;import java.io.OutputStream;
/** * Utility code for dealing with different endian systems. * <p> * Different computer architectures adopt different conventions for * byte ordering. In so-called "Little Endian" architectures (eg Intel), * the low-order byte is stored in memory at the lowest address, and * subsequent bytes at higher addresses. For "Big Endian" architectures * (eg Motorola), the situation is reversed. * This class helps you solve this incompatibility. * <p> * Origin of code: Excalibur * * @version $Id: EndianUtils.java 1686450 2015-06-19 16:43:48Z krosenvold $ * @see org.apache.commons.io.input.SwappedDataInputStream */public class EndianUtils {
/** * Instances should NOT be constructed in standard programming. */ public EndianUtils() { super(); }
// ========================================== Swapping routines
/** * Converts a "short" value between endian systems. * @param value value to convert * @return the converted value */ public static short swapShort(final short value) { return (short) ( ( ( ( value >> 0 ) & 0xff ) << 8 ) + ( ( ( value >> 8 ) & 0xff ) << 0 ) ); }
/** * Converts a "int" value between endian systems. * @param value value to convert * @return the converted value */ public static int swapInteger(final int value) { return ( ( ( value >> 0 ) & 0xff ) << 24 ) + ( ( ( value >> 8 ) & 0xff ) << 16 ) + ( ( ( value >> 16 ) & 0xff ) << 8 ) + ( ( ( value >> 24 ) & 0xff ) << 0 ); }
/** * Converts a "long" value between endian systems. * @param value value to convert * @return the converted value */ public static long swapLong(final long value) { return ( ( ( value >> 0 ) & 0xff ) << 56 ) + ( ( ( value >> 8 ) & 0xff ) << 48 ) + ( ( ( value >> 16 ) & 0xff ) << 40 ) + ( ( ( value >> 24 ) & 0xff ) << 32 ) + ( ( ( value >> 32 ) & 0xff ) << 24 ) + ( ( ( value >> 40 ) & 0xff ) << 16 ) + ( ( ( value >> 48 ) & 0xff ) << 8 ) + ( ( ( value >> 56 ) & 0xff ) << 0 ); }
/** * Converts a "float" value between endian systems. * @param value value to convert * @return the converted value */ public static float swapFloat(final float value) { return Float.intBitsToFloat( swapInteger( Float.floatToIntBits( value ) ) ); }
/** * Converts a "double" value between endian systems. * @param value value to convert * @return the converted value */ public static double swapDouble(final double value) { return Double.longBitsToDouble( swapLong( Double.doubleToLongBits( value ) ) ); }
// ========================================== Swapping read/write routines
/** * Writes a "short" value to a byte array at a given offset. The value is * converted to the opposed endian system while writing. * @param data target byte array * @param offset starting offset in the byte array * @param value value to write */ public static void writeSwappedShort(final byte[] data, final int offset, final short value) { data[ offset + 0 ] = (byte)( ( value >> 0 ) & 0xff ); data[ offset + 1 ] = (byte)( ( value >> 8 ) & 0xff ); }
/** * Reads a "short" value from a byte array at a given offset. The value is * converted to the opposed endian system while reading. * @param data source byte array * @param offset starting offset in the byte array * @return the value read */ public static short readSwappedShort(final byte[] data, final int offset) { return (short)( ( ( data[ offset + 0 ] & 0xff ) << 0 ) + ( ( data[ offset + 1 ] & 0xff ) << 8 ) ); }
/** * Reads an unsigned short (16-bit) value from a byte array at a given * offset. The value is converted to the opposed endian system while * reading. * @param data source byte array * @param offset starting offset in the byte array * @return the value read */ public static int readSwappedUnsignedShort(final byte[] data, final int offset) { return ( ( ( data[ offset + 0 ] & 0xff ) << 0 ) + ( ( data[ offset + 1 ] & 0xff ) << 8 ) ); }
/** * Writes a "int" value to a byte array at a given offset. The value is * converted to the opposed endian system while writing. * @param data target byte array * @param offset starting offset in the byte array * @param value value to write */ public static void writeSwappedInteger(final byte[] data, final int offset, final int value) { data[ offset + 0 ] = (byte)( ( value >> 0 ) & 0xff ); data[ offset + 1 ] = (byte)( ( value >> 8 ) & 0xff ); data[ offset + 2 ] = (byte)( ( value >> 16 ) & 0xff ); data[ offset + 3 ] = (byte)( ( value >> 24 ) & 0xff ); }
/** * Reads a "int" value from a byte array at a given offset. The value is * converted to the opposed endian system while reading. * @param data source byte array * @param offset starting offset in the byte array * @return the value read */ public static int readSwappedInteger(final byte[] data, final int offset) { return ( ( ( data[ offset + 0 ] & 0xff ) << 0 ) + ( ( data[ offset + 1 ] & 0xff ) << 8 ) + ( ( data[ offset + 2 ] & 0xff ) << 16 ) + ( ( data[ offset + 3 ] & 0xff ) << 24 ) ); }
/** * Reads an unsigned integer (32-bit) value from a byte array at a given * offset. The value is converted to the opposed endian system while * reading. * @param data source byte array * @param offset starting offset in the byte array * @return the value read */ public static long readSwappedUnsignedInteger(final byte[] data, final int offset) { final long low = ( ( ( data[ offset + 0 ] & 0xff ) << 0 ) + ( ( data[ offset + 1 ] & 0xff ) << 8 ) + ( ( data[ offset + 2 ] & 0xff ) << 16 ) );
final long high = data[ offset + 3 ] & 0xff;
return (high << 24) + (0xffffffffL & low); }
/** * Writes a "long" value to a byte array at a given offset. The value is * converted to the opposed endian system while writing. * @param data target byte array * @param offset starting offset in the byte array * @param value value to write */ public static void writeSwappedLong(final byte[] data, final int offset, final long value) { data[ offset + 0 ] = (byte)( ( value >> 0 ) & 0xff ); data[ offset + 1 ] = (byte)( ( value >> 8 ) & 0xff ); data[ offset + 2 ] = (byte)( ( value >> 16 ) & 0xff ); data[ offset + 3 ] = (byte)( ( value >> 24 ) & 0xff ); data[ offset + 4 ] = (byte)( ( value >> 32 ) & 0xff ); data[ offset + 5 ] = (byte)( ( value >> 40 ) & 0xff ); data[ offset + 6 ] = (byte)( ( value >> 48 ) & 0xff ); data[ offset + 7 ] = (byte)( ( value >> 56 ) & 0xff ); }
/** * Reads a "long" value from a byte array at a given offset. The value is * converted to the opposed endian system while reading. * @param data source byte array * @param offset starting offset in the byte array * @return the value read */ public static long readSwappedLong(final byte[] data, final int offset) { final long low = readSwappedInteger(data, offset); final long high = readSwappedInteger(data, offset + 4); return (high << 32) + (0xffffffffL & low); }
/** * Writes a "float" value to a byte array at a given offset. The value is * converted to the opposed endian system while writing. * @param data target byte array * @param offset starting offset in the byte array * @param value value to write */ public static void writeSwappedFloat(final byte[] data, final int offset, final float value) { writeSwappedInteger( data, offset, Float.floatToIntBits( value ) ); }
/** * Reads a "float" value from a byte array at a given offset. The value is * converted to the opposed endian system while reading. * @param data source byte array * @param offset starting offset in the byte array * @return the value read */ public static float readSwappedFloat(final byte[] data, final int offset) { return Float.intBitsToFloat( readSwappedInteger( data, offset ) ); }
/** * Writes a "double" value to a byte array at a given offset. The value is * converted to the opposed endian system while writing. * @param data target byte array * @param offset starting offset in the byte array * @param value value to write */ public static void writeSwappedDouble(final byte[] data, final int offset, final double value) { writeSwappedLong( data, offset, Double.doubleToLongBits( value ) ); }
/** * Reads a "double" value from a byte array at a given offset. The value is * converted to the opposed endian system while reading. * @param data source byte array * @param offset starting offset in the byte array * @return the value read */ public static double readSwappedDouble(final byte[] data, final int offset) { return Double.longBitsToDouble( readSwappedLong( data, offset ) ); }
/** * Writes a "short" value to an OutputStream. The value is * converted to the opposed endian system while writing. * @param output target OutputStream * @param value value to write * @throws IOException in case of an I/O problem */ public static void writeSwappedShort(final OutputStream output, final short value) throws IOException { output.write( (byte)( ( value >> 0 ) & 0xff ) ); output.write( (byte)( ( value >> 8 ) & 0xff ) ); }
/** * Reads a "short" value from an InputStream. The value is * converted to the opposed endian system while reading. * @param input source InputStream * @return the value just read * @throws IOException in case of an I/O problem */ public static short readSwappedShort(final InputStream input) throws IOException { return (short)( ( ( read( input ) & 0xff ) << 0 ) + ( ( read( input ) & 0xff ) << 8 ) ); }
/** * Reads a unsigned short (16-bit) from an InputStream. The value is * converted to the opposed endian system while reading. * @param input source InputStream * @return the value just read * @throws IOException in case of an I/O problem */ public static int readSwappedUnsignedShort(final InputStream input) throws IOException { final int value1 = read( input ); final int value2 = read( input );
return ( ( ( value1 & 0xff ) << 0 ) + ( ( value2 & 0xff ) << 8 ) ); }
/** * Writes a "int" value to an OutputStream. The value is * converted to the opposed endian system while writing. * @param output target OutputStream * @param value value to write * @throws IOException in case of an I/O problem */ public static void writeSwappedInteger(final OutputStream output, final int value) throws IOException { output.write( (byte)( ( value >> 0 ) & 0xff ) ); output.write( (byte)( ( value >> 8 ) & 0xff ) ); output.write( (byte)( ( value >> 16 ) & 0xff ) ); output.write( (byte)( ( value >> 24 ) & 0xff ) ); }
/** * Reads a "int" value from an InputStream. The value is * converted to the opposed endian system while reading. * @param input source InputStream * @return the value just read * @throws IOException in case of an I/O problem */ public static int readSwappedInteger(final InputStream input) throws IOException { final int value1 = read( input ); final int value2 = read( input ); final int value3 = read( input ); final int value4 = read( input );
return ( ( value1 & 0xff ) << 0 ) + ( ( value2 & 0xff ) << 8 ) + ( ( value3 & 0xff ) << 16 ) + ( ( value4 & 0xff ) << 24 ); }
/** * Reads a unsigned integer (32-bit) from an InputStream. The value is * converted to the opposed endian system while reading. * @param input source InputStream * @return the value just read * @throws IOException in case of an I/O problem */ public static long readSwappedUnsignedInteger(final InputStream input) throws IOException { final int value1 = read( input ); final int value2 = read( input ); final int value3 = read( input ); final int value4 = read( input );
final long low = ( ( ( value1 & 0xff ) << 0 ) + ( ( value2 & 0xff ) << 8 ) + ( ( value3 & 0xff ) << 16 ) );
final long high = value4 & 0xff;
return (high << 24) + (0xffffffffL & low); }
/** * Writes a "long" value to an OutputStream. The value is * converted to the opposed endian system while writing. * @param output target OutputStream * @param value value to write * @throws IOException in case of an I/O problem */ public static void writeSwappedLong(final OutputStream output, final long value) throws IOException { output.write( (byte)( ( value >> 0 ) & 0xff ) ); output.write( (byte)( ( value >> 8 ) & 0xff ) ); output.write( (byte)( ( value >> 16 ) & 0xff ) ); output.write( (byte)( ( value >> 24 ) & 0xff ) ); output.write( (byte)( ( value >> 32 ) & 0xff ) ); output.write( (byte)( ( value >> 40 ) & 0xff ) ); output.write( (byte)( ( value >> 48 ) & 0xff ) ); output.write( (byte)( ( value >> 56 ) & 0xff ) ); }
/** * Reads a "long" value from an InputStream. The value is * converted to the opposed endian system while reading. * @param input source InputStream * @return the value just read * @throws IOException in case of an I/O problem */ public static long readSwappedLong(final InputStream input) throws IOException { final byte[] bytes = new byte[8]; for ( int i=0; i<8; i++ ) { bytes[i] = (byte) read( input ); } return readSwappedLong( bytes, 0 ); }
/** * Writes a "float" value to an OutputStream. The value is * converted to the opposed endian system while writing. * @param output target OutputStream * @param value value to write * @throws IOException in case of an I/O problem */ public static void writeSwappedFloat(final OutputStream output, final float value) throws IOException { writeSwappedInteger( output, Float.floatToIntBits( value ) ); }
/** * Reads a "float" value from an InputStream. The value is * converted to the opposed endian system while reading. * @param input source InputStream * @return the value just read * @throws IOException in case of an I/O problem */ public static float readSwappedFloat(final InputStream input) throws IOException { return Float.intBitsToFloat( readSwappedInteger( input ) ); }
/** * Writes a "double" value to an OutputStream. The value is * converted to the opposed endian system while writing. * @param output target OutputStream * @param value value to write * @throws IOException in case of an I/O problem */ public static void writeSwappedDouble(final OutputStream output, final double value) throws IOException { writeSwappedLong( output, Double.doubleToLongBits( value ) ); }
/** * Reads a "double" value from an InputStream. The value is * converted to the opposed endian system while reading. * @param input source InputStream * @return the value just read * @throws IOException in case of an I/O problem */ public static double readSwappedDouble(final InputStream input) throws IOException { return Double.longBitsToDouble( readSwappedLong( input ) ); }
/** * Reads the next byte from the input stream. * @param input the stream * @return the byte * @throws IOException if the end of file is reached */ private static int read(final InputStream input) throws IOException { final int value = input.read();
if( EOF == value ) { throw new EOFException( "Unexpected EOF reached" ); }
return value; }}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.commons.io;
import java.io.File;
/** * Keeps track of files awaiting deletion, and deletes them when an associated * marker object is reclaimed by the garbage collector. * <p> * This utility creates a background thread to handle file deletion. * Each file to be deleted is registered with a handler object. * When the handler object is garbage collected, the file is deleted. * <p> * In an environment with multiple class loaders (a servlet container, for * example), you should consider stopping the background thread if it is no * longer needed. This is done by invoking the method * {@link #exitWhenFinished}, typically in * {@code javax.servlet.ServletContextListener.contextDestroyed(javax.servlet.ServletContextEvent)} or similar. * * @version $Id: FileCleaner.java 1680650 2015-05-20 18:36:40Z britter $ * @deprecated Use {@link FileCleaningTracker} */@Deprecatedpublic class FileCleaner { /** * The instance to use for the deprecated, static methods. */ static final FileCleaningTracker theInstance = new FileCleaningTracker();
//----------------------------------------------------------------------- /** * Track the specified file, using the provided marker, deleting the file * when the marker instance is garbage collected. * The {@link FileDeleteStrategy#NORMAL normal} deletion strategy will be used. * * @param file the file to be tracked, not null * @param marker the marker object used to track the file, not null * @throws NullPointerException if the file is null * @deprecated Use {@link FileCleaningTracker#track(File, Object)}. */ @Deprecated public static void track(final File file, final Object marker) { theInstance.track(file, marker); }
/** * Track the specified file, using the provided marker, deleting the file * when the marker instance is garbage collected. * The speified deletion strategy is used. * * @param file the file to be tracked, not null * @param marker the marker object used to track the file, not null * @param deleteStrategy the strategy to delete the file, null means normal * @throws NullPointerException if the file is null * @deprecated Use {@link FileCleaningTracker#track(File, Object, FileDeleteStrategy)}. */ @Deprecated public static void track(final File file, final Object marker, final FileDeleteStrategy deleteStrategy) { theInstance.track(file, marker, deleteStrategy); }
/** * Track the specified file, using the provided marker, deleting the file * when the marker instance is garbage collected. * The {@link FileDeleteStrategy#NORMAL normal} deletion strategy will be used. * * @param path the full path to the file to be tracked, not null * @param marker the marker object used to track the file, not null * @throws NullPointerException if the path is null * @deprecated Use {@link FileCleaningTracker#track(String, Object)}. */ @Deprecated public static void track(final String path, final Object marker) { theInstance.track(path, marker); }
/** * Track the specified file, using the provided marker, deleting the file * when the marker instance is garbage collected. * The speified deletion strategy is used. * * @param path the full path to the file to be tracked, not null * @param marker the marker object used to track the file, not null * @param deleteStrategy the strategy to delete the file, null means normal * @throws NullPointerException if the path is null * @deprecated Use {@link FileCleaningTracker#track(String, Object, FileDeleteStrategy)}. */ @Deprecated public static void track(final String path, final Object marker, final FileDeleteStrategy deleteStrategy) { theInstance.track(path, marker, deleteStrategy); }
//----------------------------------------------------------------------- /** * Retrieve the number of files currently being tracked, and therefore * awaiting deletion. * * @return the number of files being tracked * @deprecated Use {@link FileCleaningTracker#getTrackCount()}. */ @Deprecated public static int getTrackCount() { return theInstance.getTrackCount(); }
/** * Call this method to cause the file cleaner thread to terminate when * there are no more objects being tracked for deletion. * <p> * In a simple environment, you don't need this method as the file cleaner * thread will simply exit when the JVM exits. In a more complex environment, * with multiple class loaders (such as an application server), you should be * aware that the file cleaner thread will continue running even if the class * loader it was started from terminates. This can consitute a memory leak. * <p> * For example, suppose that you have developed a web application, which * contains the commons-io jar file in your WEB-INF/lib directory. In other * words, the FileCleaner class is loaded through the class loader of your * web application. If the web application is terminated, but the servlet * container is still running, then the file cleaner thread will still exist, * posing a memory leak. * <p> * This method allows the thread to be terminated. Simply call this method * in the resource cleanup code, such as * {@code javax.servlet.ServletContextListener.contextDestroyed(javax.servlet.ServletContextEvent)}. * One called, no new objects can be tracked by the file cleaner. * @deprecated Use {@link FileCleaningTracker#exitWhenFinished()}. */ @Deprecated public static synchronized void exitWhenFinished() { theInstance.exitWhenFinished(); }
/** * Returns the singleton instance, which is used by the deprecated, static methods. * This is mainly useful for code, which wants to support the new * {@link FileCleaningTracker} class while maintain compatibility with the * deprecated {@link FileCleaner}. * * @return the singleton instance */ public static FileCleaningTracker getInstance() { return theInstance; }}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.commons.io;
import java.io.File;import java.lang.ref.PhantomReference;import java.lang.ref.ReferenceQueue;import java.util.ArrayList;import java.util.Collection;import java.util.Collections;import java.util.HashSet;import java.util.List;
/** * Keeps track of files awaiting deletion, and deletes them when an associated * marker object is reclaimed by the garbage collector. * <p> * This utility creates a background thread to handle file deletion. * Each file to be deleted is registered with a handler object. * When the handler object is garbage collected, the file is deleted. * <p> * In an environment with multiple class loaders (a servlet container, for * example), you should consider stopping the background thread if it is no * longer needed. This is done by invoking the method * {@link #exitWhenFinished}, typically in * {@code javax.servlet.ServletContextListener.contextDestroyed(javax.servlet.ServletContextEvent)} or similar. * * @version $Id: FileCleaningTracker.java 1686747 2015-06-21 18:44:49Z krosenvold $ */public class FileCleaningTracker {
// Note: fields are package protected to allow use by test cases
/** * Queue of <code>Tracker</code> instances being watched. */ ReferenceQueue<Object> q = new ReferenceQueue<Object>(); /** * Collection of <code>Tracker</code> instances in existence. */ final Collection<Tracker> trackers = Collections.synchronizedSet(new HashSet<Tracker>()); // synchronized /** * Collection of File paths that failed to delete. */ final List<String> deleteFailures = Collections.synchronizedList(new ArrayList<String>()); /** * Whether to terminate the thread when the tracking is complete. */ volatile boolean exitWhenFinished = false; /** * The thread that will clean up registered files. */ Thread reaper;
//----------------------------------------------------------------------- /** * Track the specified file, using the provided marker, deleting the file * when the marker instance is garbage collected. * The {@link FileDeleteStrategy#NORMAL normal} deletion strategy will be used. * * @param file the file to be tracked, not null * @param marker the marker object used to track the file, not null * @throws NullPointerException if the file is null */ public void track(final File file, final Object marker) { track(file, marker, null); }
/** * Track the specified file, using the provided marker, deleting the file * when the marker instance is garbage collected. * The speified deletion strategy is used. * * @param file the file to be tracked, not null * @param marker the marker object used to track the file, not null * @param deleteStrategy the strategy to delete the file, null means normal * @throws NullPointerException if the file is null */ public void track(final File file, final Object marker, final FileDeleteStrategy deleteStrategy) { if (file == null) { throw new NullPointerException("The file must not be null"); } addTracker(file.getPath(), marker, deleteStrategy); }
/** * Track the specified file, using the provided marker, deleting the file * when the marker instance is garbage collected. * The {@link FileDeleteStrategy#NORMAL normal} deletion strategy will be used. * * @param path the full path to the file to be tracked, not null * @param marker the marker object used to track the file, not null * @throws NullPointerException if the path is null */ public void track(final String path, final Object marker) { track(path, marker, null); }
/** * Track the specified file, using the provided marker, deleting the file * when the marker instance is garbage collected. * The speified deletion strategy is used. * * @param path the full path to the file to be tracked, not null * @param marker the marker object used to track the file, not null * @param deleteStrategy the strategy to delete the file, null means normal * @throws NullPointerException if the path is null */ public void track(final String path, final Object marker, final FileDeleteStrategy deleteStrategy) { if (path == null) { throw new NullPointerException("The path must not be null"); } addTracker(path, marker, deleteStrategy); }
/** * Adds a tracker to the list of trackers. * * @param path the full path to the file to be tracked, not null * @param marker the marker object used to track the file, not null * @param deleteStrategy the strategy to delete the file, null means normal */ private synchronized void addTracker(final String path, final Object marker, final FileDeleteStrategy deleteStrategy) { // synchronized block protects reaper if (exitWhenFinished) { throw new IllegalStateException("No new trackers can be added once exitWhenFinished() is called"); } if (reaper == null) { reaper = new Reaper(); reaper.start(); } trackers.add(new Tracker(path, deleteStrategy, marker, q)); }
//----------------------------------------------------------------------- /** * Retrieve the number of files currently being tracked, and therefore * awaiting deletion. * * @return the number of files being tracked */ public int getTrackCount() { return trackers.size(); }
/** * Return the file paths that failed to delete. * * @return the file paths that failed to delete * @since 2.0 */ public List<String> getDeleteFailures() { return deleteFailures; }
/** * Call this method to cause the file cleaner thread to terminate when * there are no more objects being tracked for deletion. * <p> * In a simple environment, you don't need this method as the file cleaner * thread will simply exit when the JVM exits. In a more complex environment, * with multiple class loaders (such as an application server), you should be * aware that the file cleaner thread will continue running even if the class * loader it was started from terminates. This can consitute a memory leak. * <p> * For example, suppose that you have developed a web application, which * contains the commons-io jar file in your WEB-INF/lib directory. In other * words, the FileCleaner class is loaded through the class loader of your * web application. If the web application is terminated, but the servlet * container is still running, then the file cleaner thread will still exist, * posing a memory leak. * <p> * This method allows the thread to be terminated. Simply call this method * in the resource cleanup code, such as * {@code javax.servlet.ServletContextListener.contextDestroyed(javax.servlet.ServletContextEvent)}. * Once called, no new objects can be tracked by the file cleaner. */ public synchronized void exitWhenFinished() { // synchronized block protects reaper exitWhenFinished = true; if (reaper != null) { synchronized (reaper) { reaper.interrupt(); } } }
//----------------------------------------------------------------------- /** * The reaper thread. */ private final class Reaper extends Thread { /** Construct a new Reaper */ Reaper() { super("File Reaper"); setPriority(Thread.MAX_PRIORITY); setDaemon(true); }
/** * Run the reaper thread that will delete files as their associated * marker objects are reclaimed by the garbage collector. */ @Override public void run() { // thread exits when exitWhenFinished is true and there are no more tracked objects while (exitWhenFinished == false || trackers.size() > 0) { try { // Wait for a tracker to remove. final Tracker tracker = (Tracker) q.remove(); // cannot return null trackers.remove(tracker); if (!tracker.delete()) { deleteFailures.add(tracker.getPath()); } tracker.clear(); } catch (final InterruptedException e) { continue; } } } }
//----------------------------------------------------------------------- /** * Inner class which acts as the reference for a file pending deletion. */ private static final class Tracker extends PhantomReference<Object> {
/** * The full path to the file being tracked. */ private final String path; /** * The strategy for deleting files. */ private final FileDeleteStrategy deleteStrategy;
/** * Constructs an instance of this class from the supplied parameters. * * @param path the full path to the file to be tracked, not null * @param deleteStrategy the strategy to delete the file, null means normal * @param marker the marker object used to track the file, not null * @param queue the queue on to which the tracker will be pushed, not null */ Tracker(final String path, final FileDeleteStrategy deleteStrategy, final Object marker, final ReferenceQueue<? super Object> queue) { super(marker, queue); this.path = path; this.deleteStrategy = deleteStrategy == null ? FileDeleteStrategy.NORMAL : deleteStrategy; }
/** * Return the path. * * @return the path */ public String getPath() { return path; }
/** * Deletes the file associated with this tracker instance. * * @return {@code true} if the file was deleted successfully; * {@code false} otherwise. */ public boolean delete() { return deleteStrategy.deleteQuietly(new File(path)); } }
}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.commons.io;
import java.io.File;import java.io.IOException;
/** * Strategy for deleting files. * <p> * There is more than one way to delete a file. * You may want to limit access to certain directories, to only delete * directories if they are empty, or maybe to force deletion. * <p> * This class captures the strategy to use and is designed for user subclassing. * * @version $Id: FileDeleteStrategy.java 1563227 2014-01-31 19:45:30Z ggregory $ * @since 1.3 */public class FileDeleteStrategy {
/** * The singleton instance for normal file deletion, which does not permit * the deletion of directories that are not empty. */ public static final FileDeleteStrategy NORMAL = new FileDeleteStrategy("Normal"); /** * The singleton instance for forced file deletion, which always deletes, * even if the file represents a non-empty directory. */ public static final FileDeleteStrategy FORCE = new ForceFileDeleteStrategy();
/** The name of the strategy. */ private final String name;
//----------------------------------------------------------------------- /** * Restricted constructor. * * @param name the name by which the strategy is known */ protected FileDeleteStrategy(final String name) { this.name = name; }
//----------------------------------------------------------------------- /** * Deletes the file object, which may be a file or a directory. * All <code>IOException</code>s are caught and false returned instead. * If the file does not exist or is null, true is returned. * <p> * Subclass writers should override {@link #doDelete(File)}, not this method. * * @param fileToDelete the file to delete, null returns true * @return true if the file was deleted, or there was no such file */ public boolean deleteQuietly(final File fileToDelete) { if (fileToDelete == null || fileToDelete.exists() == false) { return true; } try { return doDelete(fileToDelete); } catch (final IOException ex) { return false; } }
/** * Deletes the file object, which may be a file or a directory. * If the file does not exist, the method just returns. * <p> * Subclass writers should override {@link #doDelete(File)}, not this method. * * @param fileToDelete the file to delete, not null * @throws NullPointerException if the file is null * @throws IOException if an error occurs during file deletion */ public void delete(final File fileToDelete) throws IOException { if (fileToDelete.exists() && doDelete(fileToDelete) == false) { throw new IOException("Deletion failed: " + fileToDelete); } }
/** * Actually deletes the file object, which may be a file or a directory. * <p> * This method is designed for subclasses to override. * The implementation may return either false or an <code>IOException</code> * when deletion fails. The {@link #delete(File)} and {@link #deleteQuietly(File)} * methods will handle either response appropriately. * A check has been made to ensure that the file will exist. * <p> * This implementation uses {@link File#delete()}. * * @param fileToDelete the file to delete, exists, not null * @return true if the file was deleteds * @throws NullPointerException if the file is null * @throws IOException if an error occurs during file deletion */ protected boolean doDelete(final File fileToDelete) throws IOException { return fileToDelete.delete(); }
//----------------------------------------------------------------------- /** * Gets a string describing the delete strategy. * * @return a string describing the delete strategy */ @Override public String toString() { return "FileDeleteStrategy[" + name + "]"; }
//----------------------------------------------------------------------- /** * Force file deletion strategy. */ static class ForceFileDeleteStrategy extends FileDeleteStrategy { /** Default Constructor */ ForceFileDeleteStrategy() { super("Force"); }
/** * Deletes the file object. * <p> * This implementation uses <code>FileUtils.forceDelete()</code> * if the file exists. * * @param fileToDelete the file to delete, not null * @return Always returns {@code true} * @throws NullPointerException if the file is null * @throws IOException if an error occurs during file deletion */ @Override protected boolean doDelete(final File fileToDelete) throws IOException { FileUtils.forceDelete(fileToDelete); return true; } }
}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.commons.io;
import java.io.File;import java.io.IOException;
/** * Indicates that a file already exists. * * @version $Id: FileExistsException.java 1415850 2012-11-30 20:51:39Z ggregory $ * @since 2.0 */public class FileExistsException extends IOException {
/** * Defines the serial version UID. */ private static final long serialVersionUID = 1L;
/** * Default Constructor. */ public FileExistsException() { super(); }
/** * Construct an instance with the specified message. * * @param message The error message */ public FileExistsException(final String message) { super(message); }
/** * Construct an instance with the specified file. * * @param file The file that exists */ public FileExistsException(final File file) { super("File " + file + " exists"); }
}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.commons.io;
import java.io.BufferedReader;import java.io.File;import java.io.IOException;import java.io.InputStream;import java.io.InputStreamReader;import java.io.OutputStream;import java.nio.charset.Charset;import java.util.ArrayList;import java.util.Arrays;import java.util.List;import java.util.Locale;import java.util.StringTokenizer;
/** * General File System utilities. * <p> * This class provides static utility methods for general file system * functions not provided via the JDK {@link java.io.File File} class. * <p> * The current functions provided are: * <ul> * <li>Get the free space on a drive * </ul> * * @version $Id: FileSystemUtils.java 1686747 2015-06-21 18:44:49Z krosenvold $ * @since 1.1 */public class FileSystemUtils {
/** Singleton instance, used mainly for testing. */ private static final FileSystemUtils INSTANCE = new FileSystemUtils();
/** Operating system state flag for error. */ private static final int INIT_PROBLEM = -1; /** Operating system state flag for neither Unix nor Windows. */ private static final int OTHER = 0; /** Operating system state flag for Windows. */ private static final int WINDOWS = 1; /** Operating system state flag for Unix. */ private static final int UNIX = 2; /** Operating system state flag for Posix flavour Unix. */ private static final int POSIX_UNIX = 3;
/** The operating system flag. */ private static final int OS;
/** The path to df */ private static final String DF;
static { int os = OTHER; String dfPath = "df"; try { String osName = System.getProperty("os.name"); if (osName == null) { throw new IOException("os.name not found"); } osName = osName.toLowerCase(Locale.ENGLISH); // match if (osName.contains("windows")) { os = WINDOWS; } else if (osName.contains("linux") || osName.contains("mpe/ix") || osName.contains("freebsd") || osName.contains("irix") || osName.contains("digital unix") || osName.contains("unix") || osName.contains("mac os x")) { os = UNIX; } else if (osName.contains("sun os") || osName.contains("sunos") || osName.contains("solaris")) { os = POSIX_UNIX; dfPath = "/usr/xpg4/bin/df"; } else if (osName.contains("hp-ux") || osName.contains("aix")) { os = POSIX_UNIX; } else { os = OTHER; }
} catch (final Exception ex) { os = INIT_PROBLEM; } OS = os; DF = dfPath; }
/** * Instances should NOT be constructed in standard programming. */ public FileSystemUtils() { super(); }
//----------------------------------------------------------------------- /** * Returns the free space on a drive or volume by invoking * the command line. * This method does not normalize the result, and typically returns * bytes on Windows, 512 byte units on OS X and kilobytes on Unix. * As this is not very useful, this method is deprecated in favour * of {@link #freeSpaceKb(String)} which returns a result in kilobytes. * <p> * Note that some OS's are NOT currently supported, including OS/390, * OpenVMS. * <pre> * FileSystemUtils.freeSpace("C:"); // Windows * FileSystemUtils.freeSpace("/volume"); // *nix * </pre> * The free space is calculated via the command line. * It uses 'dir /-c' on Windows and 'df' on *nix. * * @param path the path to get free space for, not null, not empty on Unix * @return the amount of free drive space on the drive or volume * @throws IllegalArgumentException if the path is invalid * @throws IllegalStateException if an error occurred in initialisation * @throws IOException if an error occurs when finding the free space * @since 1.1, enhanced OS support in 1.2 and 1.3 * @deprecated Use freeSpaceKb(String) * Deprecated from 1.3, may be removed in 2.0 */ @Deprecated public static long freeSpace(final String path) throws IOException { return INSTANCE.freeSpaceOS(path, OS, false, -1); }
//----------------------------------------------------------------------- /** * Returns the free space on a drive or volume in kilobytes by invoking * the command line. * <pre> * FileSystemUtils.freeSpaceKb("C:"); // Windows * FileSystemUtils.freeSpaceKb("/volume"); // *nix * </pre> * The free space is calculated via the command line. * It uses 'dir /-c' on Windows, 'df -kP' on AIX/HP-UX and 'df -k' on other Unix. * <p> * In order to work, you must be running Windows, or have a implementation of * Unix df that supports GNU format when passed -k (or -kP). If you are going * to rely on this code, please check that it works on your OS by running * some simple tests to compare the command line with the output from this class. * If your operating system isn't supported, please raise a JIRA call detailing * the exact result from df -k and as much other detail as possible, thanks. * * @param path the path to get free space for, not null, not empty on Unix * @return the amount of free drive space on the drive or volume in kilobytes * @throws IllegalArgumentException if the path is invalid * @throws IllegalStateException if an error occurred in initialisation * @throws IOException if an error occurs when finding the free space * @since 1.2, enhanced OS support in 1.3 */ public static long freeSpaceKb(final String path) throws IOException { return freeSpaceKb(path, -1); } /** * Returns the free space on a drive or volume in kilobytes by invoking * the command line. * <pre> * FileSystemUtils.freeSpaceKb("C:"); // Windows * FileSystemUtils.freeSpaceKb("/volume"); // *nix * </pre> * The free space is calculated via the command line. * It uses 'dir /-c' on Windows, 'df -kP' on AIX/HP-UX and 'df -k' on other Unix. * <p> * In order to work, you must be running Windows, or have a implementation of * Unix df that supports GNU format when passed -k (or -kP). If you are going * to rely on this code, please check that it works on your OS by running * some simple tests to compare the command line with the output from this class. * If your operating system isn't supported, please raise a JIRA call detailing * the exact result from df -k and as much other detail as possible, thanks. * * @param path the path to get free space for, not null, not empty on Unix * @param timeout The timeout amount in milliseconds or no timeout if the value * is zero or less * @return the amount of free drive space on the drive or volume in kilobytes * @throws IllegalArgumentException if the path is invalid * @throws IllegalStateException if an error occurred in initialisation * @throws IOException if an error occurs when finding the free space * @since 2.0 */ public static long freeSpaceKb(final String path, final long timeout) throws IOException { return INSTANCE.freeSpaceOS(path, OS, true, timeout); }
/** * Returns the disk size of the volume which holds the working directory. * <p> * Identical to: * <pre> * freeSpaceKb(new File(".").getAbsolutePath()) * </pre> * @return the amount of free drive space on the drive or volume in kilobytes * @throws IllegalStateException if an error occurred in initialisation * @throws IOException if an error occurs when finding the free space * @since 2.0 */ public static long freeSpaceKb() throws IOException { return freeSpaceKb(-1); }
/** * Returns the disk size of the volume which holds the working directory. * <p> * Identical to: * <pre> * freeSpaceKb(new File(".").getAbsolutePath()) * </pre> * @param timeout The timeout amount in milliseconds or no timeout if the value * is zero or less * @return the amount of free drive space on the drive or volume in kilobytes * @throws IllegalStateException if an error occurred in initialisation * @throws IOException if an error occurs when finding the free space * @since 2.0 */ public static long freeSpaceKb(final long timeout) throws IOException { return freeSpaceKb(new File(".").getAbsolutePath(), timeout); }
//----------------------------------------------------------------------- /** * Returns the free space on a drive or volume in a cross-platform manner. * Note that some OS's are NOT currently supported, including OS/390. * <pre> * FileSystemUtils.freeSpace("C:"); // Windows * FileSystemUtils.freeSpace("/volume"); // *nix * </pre> * The free space is calculated via the command line. * It uses 'dir /-c' on Windows and 'df' on *nix. * * @param path the path to get free space for, not null, not empty on Unix * @param os the operating system code * @param kb whether to normalize to kilobytes * @param timeout The timeout amount in milliseconds or no timeout if the value * is zero or less * @return the amount of free drive space on the drive or volume * @throws IllegalArgumentException if the path is invalid * @throws IllegalStateException if an error occurred in initialisation * @throws IOException if an error occurs when finding the free space */ long freeSpaceOS(final String path, final int os, final boolean kb, final long timeout) throws IOException { if (path == null) { throw new IllegalArgumentException("Path must not be null"); } switch (os) { case WINDOWS: return kb ? freeSpaceWindows(path, timeout) / FileUtils.ONE_KB : freeSpaceWindows(path, timeout); case UNIX: return freeSpaceUnix(path, kb, false, timeout); case POSIX_UNIX: return freeSpaceUnix(path, kb, true, timeout); case OTHER: throw new IllegalStateException("Unsupported operating system"); default: throw new IllegalStateException( "Exception caught when determining operating system"); } }
//----------------------------------------------------------------------- /** * Find free space on the Windows platform using the 'dir' command. * * @param path the path to get free space for, including the colon * @param timeout The timeout amount in milliseconds or no timeout if the value * is zero or less * @return the amount of free drive space on the drive * @throws IOException if an error occurs */ long freeSpaceWindows(String path, final long timeout) throws IOException { path = FilenameUtils.normalize(path, false); if (path.length() > 0 && path.charAt(0) != '"') { path = "\"" + path + "\""; }
// build and run the 'dir' command final String[] cmdAttribs = new String[] {"cmd.exe", "/C", "dir /a /-c " + path};
// read in the output of the command to an ArrayList final List<String> lines = performCommand(cmdAttribs, Integer.MAX_VALUE, timeout);
// now iterate over the lines we just read and find the LAST // non-empty line (the free space bytes should be in the last element // of the ArrayList anyway, but this will ensure it works even if it's // not, still assuming it is on the last non-blank line) for (int i = lines.size() - 1; i >= 0; i--) { final String line = lines.get(i); if (line.length() > 0) { return parseDir(line, path); } } // all lines are blank throw new IOException( "Command line 'dir /-c' did not return any info " + "for path '" + path + "'"); }
/** * Parses the Windows dir response last line * * @param line the line to parse * @param path the path that was sent * @return the number of bytes * @throws IOException if an error occurs */ long parseDir(final String line, final String path) throws IOException { // read from the end of the line to find the last numeric // character on the line, then continue until we find the first // non-numeric character, and everything between that and the last // numeric character inclusive is our free space bytes count int bytesStart = 0; int bytesEnd = 0; int j = line.length() - 1; innerLoop1: while (j >= 0) { final char c = line.charAt(j); if (Character.isDigit(c)) { // found the last numeric character, this is the end of // the free space bytes count bytesEnd = j + 1; break innerLoop1; } j--; } innerLoop2: while (j >= 0) { final char c = line.charAt(j); if (!Character.isDigit(c) && c != ',' && c != '.') { // found the next non-numeric character, this is the // beginning of the free space bytes count bytesStart = j + 1; break innerLoop2; } j--; } if (j < 0) { throw new IOException( "Command line 'dir /-c' did not return valid info " + "for path '" + path + "'"); }
// remove commas and dots in the bytes count final StringBuilder buf = new StringBuilder(line.substring(bytesStart, bytesEnd)); for (int k = 0; k < buf.length(); k++) { if (buf.charAt(k) == ',' || buf.charAt(k) == '.') { buf.deleteCharAt(k--); } } return parseBytes(buf.toString(), path); }
//----------------------------------------------------------------------- /** * Find free space on the *nix platform using the 'df' command. * * @param path the path to get free space for * @param kb whether to normalize to kilobytes * @param posix whether to use the POSIX standard format flag * @param timeout The timeout amount in milliseconds or no timeout if the value * is zero or less * @return the amount of free drive space on the volume * @throws IOException if an error occurs */ long freeSpaceUnix(final String path, final boolean kb, final boolean posix, final long timeout) throws IOException { if (path.isEmpty()) { throw new IllegalArgumentException("Path must not be empty"); }
// build and run the 'dir' command String flags = "-"; if (kb) { flags += "k"; } if (posix) { flags += "P"; } final String[] cmdAttribs = flags.length() > 1 ? new String[] {DF, flags, path} : new String[] {DF, path};
// perform the command, asking for up to 3 lines (header, interesting, overflow) final List<String> lines = performCommand(cmdAttribs, 3, timeout); if (lines.size() < 2) { // unknown problem, throw exception throw new IOException( "Command line '" + DF + "' did not return info as expected " + "for path '" + path + "'- response was " + lines); } final String line2 = lines.get(1); // the line we're interested in
// Now, we tokenize the string. The fourth element is what we want. StringTokenizer tok = new StringTokenizer(line2, " "); if (tok.countTokens() < 4) { // could be long Filesystem, thus data on third line if (tok.countTokens() == 1 && lines.size() >= 3) { final String line3 = lines.get(2); // the line may be interested in tok = new StringTokenizer(line3, " "); } else { throw new IOException( "Command line '" + DF + "' did not return data as expected " + "for path '" + path + "'- check path is valid"); } } else { tok.nextToken(); // Ignore Filesystem } tok.nextToken(); // Ignore 1K-blocks tok.nextToken(); // Ignore Used final String freeSpace = tok.nextToken(); return parseBytes(freeSpace, path); }
//----------------------------------------------------------------------- /** * Parses the bytes from a string. * * @param freeSpace the free space string * @param path the path * @return the number of bytes * @throws IOException if an error occurs */ long parseBytes(final String freeSpace, final String path) throws IOException { try { final long bytes = Long.parseLong(freeSpace); if (bytes < 0) { throw new IOException( "Command line '" + DF + "' did not find free space in response " + "for path '" + path + "'- check path is valid"); } return bytes;
} catch (final NumberFormatException ex) { throw new IOException( "Command line '" + DF + "' did not return numeric data as expected " + "for path '" + path + "'- check path is valid", ex); } }
//----------------------------------------------------------------------- /** * Performs the os command. * * @param cmdAttribs the command line parameters * @param max The maximum limit for the lines returned * @param timeout The timeout amount in milliseconds or no timeout if the value * is zero or less * @return the lines returned by the command, converted to lower-case * @throws IOException if an error occurs */ List<String> performCommand(final String[] cmdAttribs, final int max, final long timeout) throws IOException { // this method does what it can to avoid the 'Too many open files' error // based on trial and error and these links: // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4784692 // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4801027 // http://forum.java.sun.com/thread.jspa?threadID=533029&messageID=2572018 // however, its still not perfect as the JDK support is so poor // (see commons-exec or Ant for a better multi-threaded multi-os solution)
final List<String> lines = new ArrayList<String>(20); Process proc = null; InputStream in = null; OutputStream out = null; InputStream err = null; BufferedReader inr = null; try {
final Thread monitor = ThreadMonitor.start(timeout);
proc = openProcess(cmdAttribs); in = proc.getInputStream(); out = proc.getOutputStream(); err = proc.getErrorStream(); // default charset is most likely appropriate here inr = new BufferedReader(new InputStreamReader(in, Charset.defaultCharset())); String line = inr.readLine(); while (line != null && lines.size() < max) { line = line.toLowerCase(Locale.ENGLISH).trim(); lines.add(line); line = inr.readLine(); }
proc.waitFor();
ThreadMonitor.stop(monitor);
if (proc.exitValue() != 0) { // os command problem, throw exception throw new IOException( "Command line returned OS error code '" + proc.exitValue() + "' for command " + Arrays.asList(cmdAttribs)); } if (lines.isEmpty()) { // unknown problem, throw exception throw new IOException( "Command line did not return any info " + "for command " + Arrays.asList(cmdAttribs)); } return lines;
} catch (final InterruptedException ex) { throw new IOException( "Command line threw an InterruptedException " + "for command " + Arrays.asList(cmdAttribs) + " timeout=" + timeout, ex); } finally { IOUtils.closeQuietly(in); IOUtils.closeQuietly(out); IOUtils.closeQuietly(err); IOUtils.closeQuietly(inr); if (proc != null) { proc.destroy(); } } }
/** * Opens the process to the operating system. * * @param cmdAttribs the command line parameters * @return the process * @throws IOException if an error occurs */ Process openProcess(final String[] cmdAttribs) throws IOException { return Runtime.getRuntime().exec(cmdAttribs); }
}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.commons.io;
import java.io.File;import java.io.IOException;import java.util.ArrayList;import java.util.Collection;import java.util.Stack;
/** * General filename and filepath manipulation utilities. * <p> * When dealing with filenames 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 {@link java.io.File File} objects and the two argument constructor * {@link java.io.File#File(java.io.File, java.lang.String) File(File,String)}. * <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 recognise 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 filename * (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 filenames end with a separator. * If you omit the last separator, it is impossible to determine if the filename * 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. * * @version $Id: FilenameUtils.java 1702170 2015-09-10 06:35:02Z krosenvold $ * @since 1.1 */public class FilenameUtils {
private static final int NOT_FOUND = -1;
/** * The extension separator character. * @since 1.4 */ public static final char EXTENSION_SEPARATOR = '.';
/** * The extension separator String. * @since 1.4 */ public static final String EXTENSION_SEPARATOR_STR = Character.toString(EXTENSION_SEPARATOR);
/** * The Unix separator character. */ private static final char UNIX_SEPARATOR = '/';
/** * The Windows separator character. */ private static final char WINDOWS_SEPARATOR = '\\';
/** * The system separator character. */ private static final char SYSTEM_SEPARATOR = File.separatorChar;
/** * The separator character that is the opposite of the system separator. */ private static final char OTHER_SEPARATOR; static { if (isSystemWindows()) { OTHER_SEPARATOR = UNIX_SEPARATOR; } else { OTHER_SEPARATOR = WINDOWS_SEPARATOR; } }
/** * Instances should NOT be constructed in standard programming. */ public FilenameUtils() { super(); }
//----------------------------------------------------------------------- /** * Determines if Windows file system is in use. * * @return true if the system is Windows */ static boolean isSystemWindows() { return SYSTEM_SEPARATOR == WINDOWS_SEPARATOR; }
//----------------------------------------------------------------------- /** * Checks if the character is a separator. * * @param ch the character to check * @return true if it is a separator character */ private static boolean isSeparator(final char ch) { return ch == UNIX_SEPARATOR || ch == WINDOWS_SEPARATOR; }
//----------------------------------------------------------------------- /** * 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} * 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) * * @param filename the filename to normalize, null returns null * @return the normalized filename, or null if invalid. Null bytes inside string will be removed */ public static String normalize(final String filename) { return doNormalize(filename, SYSTEM_SEPARATOR, true); } /** * 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} * 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. * * @param filename the filename to normalize, null returns null * @param unixSeparator {@code true} if a unix separator should * be used or {@code false} if a windows separator should be used. * @return the normalized filename, or null if invalid. Null bytes inside string will be removed * @since 2.0 */ public static String normalize(final String filename, final boolean unixSeparator) { final char separator = unixSeparator ? UNIX_SEPARATOR : WINDOWS_SEPARATOR; return doNormalize(filename, separator, true); }
//----------------------------------------------------------------------- /** * 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} * 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) * * @param filename the filename to normalize, null returns null * @return the normalized filename, or null if invalid. Null bytes inside string will be removed */ public static String normalizeNoEndSeparator(final String filename) { return doNormalize(filename, SYSTEM_SEPARATOR, false); }
/** * 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} * 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> * * @param filename the filename to normalize, null returns null * @param unixSeparator {@code true} if a unix separator should * be used or {@code false} if a windows separtor should be used. * @return the normalized filename, or null if invalid. Null bytes inside string will be removed * @since 2.0 */ public static String normalizeNoEndSeparator(final String filename, final boolean unixSeparator) { final char separator = unixSeparator ? UNIX_SEPARATOR : WINDOWS_SEPARATOR; return doNormalize(filename, separator, false); }
/** * Internal method to perform the normalization. * * @param filename the filename * @param separator The separator character to use * @param keepSeparator true to keep the final separator * @return the normalized filename. Null bytes inside string will be removed. */ private static String doNormalize(final String filename, final char separator, final boolean keepSeparator) { if (filename == null) { return null; }
failIfNullBytePresent(filename);
int size = filename.length(); if (size == 0) { return filename; } final int prefix = getPrefixLength(filename); if (prefix < 0) { return null; }
final char[] array = new char[size + 2]; // +1 for possible extra slash, +2 for arraycopy filename.getChars(0, filename.length(), array, 0);
// fix separators throughout final char otherSeparator = separator == SYSTEM_SEPARATOR ? OTHER_SEPARATOR : SYSTEM_SEPARATOR; for (int i = 0; i < array.length; i++) { if (array[i] == otherSeparator) { array[i] = separator; } }
// add extra separator on the end to simplify code below boolean lastIsDirectory = true; if (array[size - 1] != separator) { array[size++] = separator; lastIsDirectory = false; }
// adjoining slashes for (int i = prefix + 1; i < size; i++) { if (array[i] == separator && array[i - 1] == separator) { System.arraycopy(array, i, array, i - 1, size - i); size--; i--; } }
// dot slash for (int i = prefix + 1; i < size; i++) { if (array[i] == separator && array[i - 1] == '.' && (i == prefix + 1 || array[i - 2] == separator)) { if (i == size - 1) { lastIsDirectory = true; } System.arraycopy(array, i + 1, array, i - 1, size - i); size -=2; i--; } }
// double dot slash outer: for (int i = prefix + 2; i < size; i++) { if (array[i] == separator && array[i - 1] == '.' && array[i - 2] == '.' && (i == prefix + 2 || array[i - 3] == separator)) { if (i == prefix + 2) { return null; } if (i == size - 1) { lastIsDirectory = true; } int j; for (j = i - 4 ; j >= prefix; j--) { if (array[j] == separator) { // remove b/../ from a/b/../c System.arraycopy(array, i + 1, array, j + 1, size - i); size -= i - j; i = j + 1; continue outer; } } // remove a/../ from a/../c System.arraycopy(array, i + 1, array, prefix, size - i); size -= i + 1 - prefix; i = prefix + 1; } }
if (size <= 0) { // should never be less than 0 return ""; } if (size <= prefix) { // should never be less than prefix return new String(array, 0, size); } if (lastIsDirectory && keepSeparator) { return new String(array, 0, size); // keep trailing separator } return new String(array, 0, size - 1); // lose trailing separator }
//----------------------------------------------------------------------- /** * 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 {@link #normalize(String)}, * 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 {@link #getFullPath(String)} on the base path argument. * * @param basePath the base path to attach to, always treated as a path * @param fullFilenameToAdd the filename (or path) to attach to the base * @return the concatenated path, or null if invalid. Null bytes inside string will be removed */ public static String concat(final String basePath, final String fullFilenameToAdd) { final int prefix = getPrefixLength(fullFilenameToAdd); if (prefix < 0) { return null; } if (prefix > 0) { return normalize(fullFilenameToAdd); } if (basePath == null) { return null; } final int len = basePath.length(); if (len == 0) { return normalize(fullFilenameToAdd); } final char ch = basePath.charAt(len - 1); if (isSeparator(ch)) { return normalize(basePath + fullFilenameToAdd); } else { return normalize(basePath + '/' + fullFilenameToAdd); } }
/** * Determines whether the {@code parent} directory contains the {@code child} element (a file or directory). * <p> * The files names are expected to be normalized. * </p> * * Edge cases: * <ul> * <li>A {@code directory} 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> * * @param canonicalParent * the file to consider as the parent. * @param canonicalChild * the file to consider as the child. * @return true is the candidate leaf is under by the specified composite. False otherwise. * @throws IOException * if an IO error occurs while checking the files. * @since 2.2 * @see FileUtils#directoryContains(File, File) */ public static boolean directoryContains(final String canonicalParent, final String canonicalChild) throws IOException {
// Fail fast against NullPointerException if (canonicalParent == null) { throw new IllegalArgumentException("Directory must not be null"); }
if (canonicalChild == null) { return false; }
if (IOCase.SYSTEM.checkEquals(canonicalParent, canonicalChild)) { return false; }
return IOCase.SYSTEM.checkStartsWith(canonicalChild, canonicalParent); }
//----------------------------------------------------------------------- /** * Converts all separators to the Unix separator of forward slash. * * @param path the path to be changed, null ignored * @return the updated path */ public static String separatorsToUnix(final String path) { if (path == null || path.indexOf(WINDOWS_SEPARATOR) == NOT_FOUND) { return path; } return path.replace(WINDOWS_SEPARATOR, UNIX_SEPARATOR); }
/** * Converts all separators to the Windows separator of backslash. * * @param path the path to be changed, null ignored * @return the updated path */ public static String separatorsToWindows(final String path) { if (path == null || path.indexOf(UNIX_SEPARATOR) == NOT_FOUND) { return path; } return path.replace(UNIX_SEPARATOR, WINDOWS_SEPARATOR); }
/** * Converts all separators to the system separator. * * @param path the path to be changed, null ignored * @return the updated path */ public static String separatorsToSystem(final String path) { if (path == null) { return null; } if (isSystemWindows()) { return separatorsToWindows(path); } else { return separatorsToUnix(path); } }
//----------------------------------------------------------------------- /** * 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 --> "" --> 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 * \\\a\b\c.txt --> error, length = -1 * * 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) * //server/a/b/c.txt --> "//server/" * ///a/b/c.txt --> error, length = -1 * </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. * * @param filename the filename to find the prefix in, null returns -1 * @return the length of the prefix, -1 if invalid or null */ public static int getPrefixLength(final String filename) { if (filename == null) { return NOT_FOUND; } final int len = filename.length(); if (len == 0) { return 0; } char ch0 = filename.charAt(0); if (ch0 == ':') { return NOT_FOUND; } if (len == 1) { if (ch0 == '~') { return 2; // return a length greater than the input } return isSeparator(ch0) ? 1 : 0; } else { if (ch0 == '~') { int posUnix = filename.indexOf(UNIX_SEPARATOR, 1); int posWin = filename.indexOf(WINDOWS_SEPARATOR, 1); if (posUnix == NOT_FOUND && posWin == NOT_FOUND) { return len + 1; // return a length greater than the input } posUnix = posUnix == NOT_FOUND ? posWin : posUnix; posWin = posWin == NOT_FOUND ? posUnix : posWin; return Math.min(posUnix, posWin) + 1; } final char ch1 = filename.charAt(1); if (ch1 == ':') { ch0 = Character.toUpperCase(ch0); if (ch0 >= 'A' && ch0 <= 'Z') { if (len == 2 || isSeparator(filename.charAt(2)) == false) { return 2; } return 3; } return NOT_FOUND;
} else if (isSeparator(ch0) && isSeparator(ch1)) { int posUnix = filename.indexOf(UNIX_SEPARATOR, 2); int posWin = filename.indexOf(WINDOWS_SEPARATOR, 2); if (posUnix == NOT_FOUND && posWin == NOT_FOUND || posUnix == 2 || posWin == 2) { return NOT_FOUND; } posUnix = posUnix == NOT_FOUND ? posWin : posUnix; posWin = posWin == NOT_FOUND ? posUnix : posWin; return Math.min(posUnix, posWin) + 1; } else { return isSeparator(ch0) ? 1 : 0; } } }
/** * 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. * * @param filename the filename to find the last path separator in, null returns -1 * @return the index of the last separator character, or -1 if there * is no such character */ public static int indexOfLastSeparator(final String filename) { if (filename == null) { return NOT_FOUND; } final int lastUnixPos = filename.lastIndexOf(UNIX_SEPARATOR); final int lastWindowsPos = filename.lastIndexOf(WINDOWS_SEPARATOR); return Math.max(lastUnixPos, lastWindowsPos); }
/** * 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 * {@link #indexOfLastSeparator(String)} 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. * </p> * * @param filename * the filename to find the last extension separator in, null returns -1 * @return the index of the last extension separator character, or -1 if there is no such character */ public static int indexOfExtension(final String filename) { if (filename == null) { return NOT_FOUND; } final int extensionPos = filename.lastIndexOf(EXTENSION_SEPARATOR); final int lastSeparator = indexOfLastSeparator(filename); return lastSeparator > extensionPos ? NOT_FOUND : extensionPos; }
//----------------------------------------------------------------------- /** * 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. * * @param filename the filename to query, null returns null * @return the prefix of the file, null if invalid. Null bytes inside string will be removed */ public static String getPrefix(final String filename) { if (filename == null) { return null; } final int len = getPrefixLength(filename); if (len < 0) { return null; } if (len > filename.length()) { failIfNullBytePresent(filename + UNIX_SEPARATOR); return filename + UNIX_SEPARATOR; } String path = filename.substring(0, len); failIfNullBytePresent(path); return path; }
/** * 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 {@link #getFullPath(String)} for the method that retains the prefix. * * @param filename the filename to query, null returns null * @return the path of the file, an empty string if none exists, null if invalid. * Null bytes inside string will be removed */ public static String getPath(final String filename) { return doGetPath(filename, 1); }
/** * 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 {@link #getFullPathNoEndSeparator(String)} for the method that retains the prefix. * * @param filename the filename to query, null returns null * @return the path of the file, an empty string if none exists, null if invalid. * Null bytes inside string will be removed */ public static String getPathNoEndSeparator(final String filename) { return doGetPath(filename, 0); }
/** * Does the work of getting the path. * * @param filename the filename * @param separatorAdd 0 to omit the end separator, 1 to return it * @return the path. Null bytes inside string will be removed */ private static String doGetPath(final String filename, final int separatorAdd) { if (filename == null) { return null; } final int prefix = getPrefixLength(filename); if (prefix < 0) { return null; } final int index = indexOfLastSeparator(filename); final int endIndex = index+separatorAdd; if (prefix >= filename.length() || index < 0 || prefix >= endIndex) { return ""; } String path = filename.substring(prefix, endIndex); failIfNullBytePresent(path); return path; }
/** * 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. * * @param filename the filename to query, null returns null * @return the path of the file, an empty string if none exists, null if invalid */ public static String getFullPath(final String filename) { return doGetFullPath(filename, true); }
/** * 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. * * @param filename the filename to query, null returns null * @return the path of the file, an empty string if none exists, null if invalid */ public static String getFullPathNoEndSeparator(final String filename) { return doGetFullPath(filename, false); }
/** * Does the work of getting the path. * * @param filename the filename * @param includeSeparator true to include the end separator * @return the path */ private static String doGetFullPath(final String filename, final boolean includeSeparator) { if (filename == null) { return null; } final int prefix = getPrefixLength(filename); if (prefix < 0) { return null; } if (prefix >= filename.length()) { if (includeSeparator) { return getPrefix(filename); // add end slash if necessary } else { return filename; } } final int index = indexOfLastSeparator(filename); if (index < 0) { return filename.substring(0, prefix); } int end = index + (includeSeparator ? 1 : 0); if (end == 0) { end++; } return filename.substring(0, end); }
/** * 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. * * @param filename the filename to query, null returns null * @return the name of the file without the path, or an empty string if none exists. * Null bytes inside string will be removed */ public static String getName(final String filename) { if (filename == null) { return null; } failIfNullBytePresent(filename); final int index = indexOfLastSeparator(filename); return filename.substring(index + 1); }
/** * Check the input for null bytes, a sign of unsanitized data being passed to to file level functions. * * This may be used for poison byte attacks. * @param path the path to check */ private static void failIfNullBytePresent(String path) { int len = path.length(); for (int i = 0; i < len; i++) { if (path.charAt(i) == 0) { throw new IllegalArgumentException("Null byte present in file/path name. There are no " + "known legitimate use cases for such data, but several injection attacks may use it"); } } }
/** * 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. * * @param filename the filename to query, null returns null * @return the name of the file without the path, or an empty string if none exists. Null bytes inside string * will be removed */ public static String getBaseName(final String filename) { return removeExtension(getName(filename)); }
/** * 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. * * @param filename the filename to retrieve the extension of. * @return the extension of the file or an empty string if none exists or {@code null} * if the filename is {@code null}. */ public static String getExtension(final String filename) { if (filename == null) { return null; } final int index = indexOfExtension(filename); if (index == NOT_FOUND) { return ""; } else { return filename.substring(index + 1); } }
//----------------------------------------------------------------------- /** * 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. * * @param filename the filename to query, null returns null * @return the filename minus the extension */ public static String removeExtension(final String filename) { if (filename == null) { return null; } failIfNullBytePresent(filename);
final int index = indexOfExtension(filename); if (index == NOT_FOUND) { return filename; } else { return filename.substring(0, index); } }
//----------------------------------------------------------------------- /** * 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. * * @param filename1 the first filename to query, may be null * @param filename2 the second filename to query, may be null * @return true if the filenames are equal, null equals null * @see IOCase#SENSITIVE */ public static boolean equals(final String filename1, final String filename2) { return equals(filename1, filename2, false, IOCase.SENSITIVE); }
/** * 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. * * @param filename1 the first filename to query, may be null * @param filename2 the second filename to query, may be null * @return true if the filenames are equal, null equals null * @see IOCase#SYSTEM */ public static boolean equalsOnSystem(final String filename1, final String filename2) { return equals(filename1, filename2, false, IOCase.SYSTEM); }
//----------------------------------------------------------------------- /** * Checks whether two filenames are equal after both have been normalized. * <p> * Both filenames are first passed to {@link #normalize(String)}. * The check is then performed in a case-sensitive manner. * * @param filename1 the first filename to query, may be null * @param filename2 the second filename to query, may be null * @return true if the filenames are equal, null equals null * @see IOCase#SENSITIVE */ public static boolean equalsNormalized(final String filename1, final String filename2) { return equals(filename1, filename2, true, IOCase.SENSITIVE); }
/** * 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 {@link #normalize(String)}. * The check is then performed case-sensitive on Unix and * case-insensitive on Windows. * * @param filename1 the first filename to query, may be null * @param filename2 the second filename to query, may be null * @return true if the filenames are equal, null equals null * @see IOCase#SYSTEM */ public static boolean equalsNormalizedOnSystem(final String filename1, final String filename2) { return equals(filename1, filename2, true, IOCase.SYSTEM); }
/** * Checks whether two filenames are equal, optionally normalizing and providing * control over the case-sensitivity. * * @param filename1 the first filename to query, may be null * @param filename2 the second filename to query, may be null * @param normalized whether to normalize the filenames * @param caseSensitivity what case sensitivity rule to use, null means case-sensitive * @return true if the filenames are equal, null equals null * @since 1.3 */ public static boolean equals( String filename1, String filename2, final boolean normalized, IOCase caseSensitivity) {
if (filename1 == null || filename2 == null) { return filename1 == null && filename2 == null; } if (normalized) { filename1 = normalize(filename1); filename2 = normalize(filename2); if (filename1 == null || filename2 == null) { throw new NullPointerException( "Error normalizing one or both of the file names"); } } if (caseSensitivity == null) { caseSensitivity = IOCase.SENSITIVE; } return caseSensitivity.checkEquals(filename1, filename2); }
//----------------------------------------------------------------------- /** * 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. * * @param filename the filename to query, null returns false * @param extension the extension to check for, null or empty checks for no extension * @return true if the filename has the specified extension * @throws java.lang.IllegalArgumentException if the supplied filename contains null bytes */ public static boolean isExtension(final String filename, final String extension) { if (filename == null) { return false; } failIfNullBytePresent(filename);
if (extension == null || extension.isEmpty()) { return indexOfExtension(filename) == NOT_FOUND; } final String fileExt = getExtension(filename); return fileExt.equals(extension); }
/** * 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. * * @param filename the filename to query, null returns false * @param extensions the extensions to check for, null checks for no extension * @return true if the filename is one of the extensions * @throws java.lang.IllegalArgumentException if the supplied filename contains null bytes */ public static boolean isExtension(final String filename, final String[] extensions) { if (filename == null) { return false; } failIfNullBytePresent(filename);
if (extensions == null || extensions.length == 0) { return indexOfExtension(filename) == NOT_FOUND; } final String fileExt = getExtension(filename); for (final String extension : extensions) { if (fileExt.equals(extension)) { return true; } } return false; }
/** * 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. * * @param filename the filename to query, null returns false * @param extensions the extensions to check for, null checks for no extension * @return true if the filename is one of the extensions * @throws java.lang.IllegalArgumentException if the supplied filename contains null bytes */ public static boolean isExtension(final String filename, final Collection<String> extensions) { if (filename == null) { return false; } failIfNullBytePresent(filename);
if (extensions == null || extensions.isEmpty()) { return indexOfExtension(filename) == NOT_FOUND; } final String fileExt = getExtension(filename); for (final String extension : extensions) { if (fileExt.equals(extension)) { return true; } } return false; }
//----------------------------------------------------------------------- /** * 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. * * @param filename the filename to match on * @param wildcardMatcher the wildcard string to match against * @return true if the filename matches the wilcard string * @see IOCase#SENSITIVE */ public static boolean wildcardMatch(final String filename, final String wildcardMatcher) { return wildcardMatch(filename, wildcardMatcher, IOCase.SENSITIVE); }
/** * 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. * * @param filename the filename to match on * @param wildcardMatcher the wildcard string to match against * @return true if the filename matches the wilcard string * @see IOCase#SYSTEM */ public static boolean wildcardMatchOnSystem(final String filename, final String wildcardMatcher) { return wildcardMatch(filename, wildcardMatcher, IOCase.SYSTEM); }
/** * 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. * * @param filename the filename to match on * @param wildcardMatcher the wildcard string to match against * @param caseSensitivity what case sensitivity rule to use, null means case-sensitive * @return true if the filename matches the wilcard string * @since 1.3 */ public static boolean wildcardMatch(final String filename, final String wildcardMatcher, IOCase caseSensitivity) { if (filename == null && wildcardMatcher == null) { return true; } if (filename == null || wildcardMatcher == null) { return false; } if (caseSensitivity == null) { caseSensitivity = IOCase.SENSITIVE; } final String[] wcs = splitOnTokens(wildcardMatcher); boolean anyChars = false; int textIdx = 0; int wcsIdx = 0; final Stack<int[]> backtrack = new Stack<int[]>();
// loop around a backtrack stack, to handle complex * matching do { if (backtrack.size() > 0) { final int[] array = backtrack.pop(); wcsIdx = array[0]; textIdx = array[1]; anyChars = true; }
// loop whilst tokens and text left to process while (wcsIdx < wcs.length) {
if (wcs[wcsIdx].equals("?")) { // ? so move to next text char textIdx++; if (textIdx > filename.length()) { break; } anyChars = false;
} else if (wcs[wcsIdx].equals("*")) { // set any chars status anyChars = true; if (wcsIdx == wcs.length - 1) { textIdx = filename.length(); }
} else { // matching text token if (anyChars) { // any chars then try to locate text token textIdx = caseSensitivity.checkIndexOf(filename, textIdx, wcs[wcsIdx]); if (textIdx == NOT_FOUND) { // token not found break; } final int repeat = caseSensitivity.checkIndexOf(filename, textIdx + 1, wcs[wcsIdx]); if (repeat >= 0) { backtrack.push(new int[] {wcsIdx, repeat}); } } else { // matching from current position if (!caseSensitivity.checkRegionMatches(filename, textIdx, wcs[wcsIdx])) { // couldnt match token break; } }
// matched text token, move text index to end of matched token textIdx += wcs[wcsIdx].length(); anyChars = false; }
wcsIdx++; }
// full match if (wcsIdx == wcs.length && textIdx == filename.length()) { return true; }
} while (backtrack.size() > 0);
return false; }
/** * Splits a string into a number of tokens. * The text is split by '?' and '*'. * Where multiple '*' occur consecutively they are collapsed into a single '*'. * * @param text the text to split * @return the array of tokens, never null */ static String[] splitOnTokens(final String text) { // used by wildcardMatch // package level so a unit test may run on this
if (text.indexOf('?') == NOT_FOUND && text.indexOf('*') == NOT_FOUND) { return new String[] { text }; }
final char[] array = text.toCharArray(); final ArrayList<String> list = new ArrayList<String>(); final StringBuilder buffer = new StringBuilder(); char prevChar = 0; for (final char ch : array) { if (ch == '?' || ch == '*') { if (buffer.length() != 0) { list.add(buffer.toString()); buffer.setLength(0); } if (ch == '?') { list.add("?"); } else if (prevChar != '*') {// ch == '*' here; check if previous char was '*' list.add("*"); } } else { buffer.append(ch); } prevChar = ch; } if (buffer.length() != 0) { list.add(buffer.toString()); }
return list.toArray( new String[ list.size() ] ); }
}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.commons.io;
import java.io.IOException;import java.io.OutputStream;import java.nio.charset.Charset;
/** * Dumps data in hexadecimal format. * <p> * Provides a single function to take an array of bytes and display it * in hexadecimal form. * <p> * Origin of code: POI. * * @version $Id: HexDump.java 1471767 2013-04-24 23:24:19Z sebb $ */public class HexDump {
/** * Instances should NOT be constructed in standard programming. */ public HexDump() { super(); }
/** * Dump an array of bytes to an OutputStream. The output is formatted * for human inspection, with a hexadecimal offset followed by the * hexadecimal values of the next 16 bytes of data and the printable ASCII * characters (if any) that those bytes represent printed per each line * of output. * <p> * The offset argument specifies the start offset of the data array * within a larger entity like a file or an incoming stream. For example, * if the data array contains the third kibibyte of a file, then the * offset argument should be set to 2048. The offset value printed * at the beginning of each line indicates where in that larger entity * the first byte on that line is located. * <p> * All bytes between the given index (inclusive) and the end of the * data array are dumped. * * @param data the byte array to be dumped * @param offset offset of the byte array within a larger entity * @param stream the OutputStream to which the data is to be * written * @param index initial index into the byte array * * @throws IOException is thrown if anything goes wrong writing * the data to stream * @throws ArrayIndexOutOfBoundsException if the index is * outside the data array's bounds * @throws IllegalArgumentException if the output stream is null */
public static void dump(final byte[] data, final long offset, final OutputStream stream, final int index) throws IOException, ArrayIndexOutOfBoundsException, IllegalArgumentException {
if (index < 0 || index >= data.length) { throw new ArrayIndexOutOfBoundsException( "illegal index: " + index + " into array of length " + data.length); } if (stream == null) { throw new IllegalArgumentException("cannot write to nullstream"); } long display_offset = offset + index; final StringBuilder buffer = new StringBuilder(74);
for (int j = index; j < data.length; j += 16) { int chars_read = data.length - j;
if (chars_read > 16) { chars_read = 16; } dump(buffer, display_offset).append(' '); for (int k = 0; k < 16; k++) { if (k < chars_read) { dump(buffer, data[k + j]); } else { buffer.append(" "); } buffer.append(' '); } for (int k = 0; k < chars_read; k++) { if (data[k + j] >= ' ' && data[k + j] < 127) { buffer.append((char) data[k + j]); } else { buffer.append('.'); } } buffer.append(EOL); // make explicit the dependency on the default encoding stream.write(buffer.toString().getBytes(Charset.defaultCharset())); stream.flush(); buffer.setLength(0); display_offset += chars_read; } }
/** * The line-separator (initializes to "line.separator" system property. */ public static final String EOL = System.getProperty("line.separator"); private static final char[] _hexcodes = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; private static final int[] _shifts = { 28, 24, 20, 16, 12, 8, 4, 0 };
/** * Dump a long value into a StringBuilder. * * @param _lbuffer the StringBuilder to dump the value in * @param value the long value to be dumped * @return StringBuilder containing the dumped value. */ private static StringBuilder dump(final StringBuilder _lbuffer, final long value) { for (int j = 0; j < 8; j++) { _lbuffer .append(_hexcodes[(int) (value >> _shifts[j]) & 15]); } return _lbuffer; }
/** * Dump a byte value into a StringBuilder. * * @param _cbuffer the StringBuilder to dump the value in * @param value the byte value to be dumped * @return StringBuilder containing the dumped value. */ private static StringBuilder dump(final StringBuilder _cbuffer, final byte value) { for (int j = 0; j < 2; j++) { _cbuffer.append(_hexcodes[value >> _shifts[j + 6] & 15]); } return _cbuffer; }
}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.commons.io;
import java.io.Serializable;
/** * Enumeration of IO case sensitivity. * <p> * Different filing systems have different rules for case-sensitivity. * Windows is case-insensitive, Unix is case-sensitive. * <p> * This class captures that difference, providing an enumeration to * control how filename comparisons should be performed. It also provides * methods that use the enumeration to perform comparisons. * <p> * Wherever possible, you should use the <code>check</code> methods in this * class to compare filenames. * * @version $Id: IOCase.java 1483915 2013-05-17 17:02:35Z sebb $ * @since 1.3 */public enum IOCase implements Serializable {
/** * The constant for case sensitive regardless of operating system. */ SENSITIVE ("Sensitive", true),
/** * The constant for case insensitive regardless of operating system. */ INSENSITIVE ("Insensitive", false),
/** * The constant for case sensitivity determined by the current operating system. * Windows is case-insensitive when comparing filenames, Unix is case-sensitive. * <p> * <strong>Note:</strong> This only caters for Windows and Unix. Other operating * systems (e.g. OSX and OpenVMS) are treated as case sensitive if they use the * Unix file separator and case-insensitive if they use the Windows file separator * (see {@link java.io.File#separatorChar}). * <p> * If you derialize this constant of Windows, and deserialize on Unix, or vice * versa, then the value of the case-sensitivity flag will change. */ SYSTEM ("System", !FilenameUtils.isSystemWindows());
/** Serialization version. */ private static final long serialVersionUID = -6343169151696340687L;
/** The enumeration name. */ private final String name;
/** The sensitivity flag. */ private final transient boolean sensitive;
//----------------------------------------------------------------------- /** * Factory method to create an IOCase from a name. * * @param name the name to find * @return the IOCase object * @throws IllegalArgumentException if the name is invalid */ public static IOCase forName(final String name) { for (IOCase ioCase : IOCase.values()) { if (ioCase.getName().equals(name)) { return ioCase; } } throw new IllegalArgumentException("Invalid IOCase name: " + name); }
//----------------------------------------------------------------------- /** * Private constructor. * * @param name the name * @param sensitive the sensitivity */ private IOCase(final String name, final boolean sensitive) { this.name = name; this.sensitive = sensitive; }
/** * Replaces the enumeration from the stream with a real one. * This ensures that the correct flag is set for SYSTEM. * * @return the resolved object */ private Object readResolve() { return forName(name); }
//----------------------------------------------------------------------- /** * Gets the name of the constant. * * @return the name of the constant */ public String getName() { return name; }
/** * Does the object represent case sensitive comparison. * * @return true if case sensitive */ public boolean isCaseSensitive() { return sensitive; }
//----------------------------------------------------------------------- /** * Compares two strings using the case-sensitivity rule. * <p> * This method mimics {@link String#compareTo} but takes case-sensitivity * into account. * * @param str1 the first string to compare, not null * @param str2 the second string to compare, not null * @return true if equal using the case rules * @throws NullPointerException if either string is null */ public int checkCompareTo(final String str1, final String str2) { if (str1 == null || str2 == null) { throw new NullPointerException("The strings must not be null"); } return sensitive ? str1.compareTo(str2) : str1.compareToIgnoreCase(str2); }
/** * Compares two strings using the case-sensitivity rule. * <p> * This method mimics {@link String#equals} but takes case-sensitivity * into account. * * @param str1 the first string to compare, not null * @param str2 the second string to compare, not null * @return true if equal using the case rules * @throws NullPointerException if either string is null */ public boolean checkEquals(final String str1, final String str2) { if (str1 == null || str2 == null) { throw new NullPointerException("The strings must not be null"); } return sensitive ? str1.equals(str2) : str1.equalsIgnoreCase(str2); }
/** * Checks if one string starts with another using the case-sensitivity rule. * <p> * This method mimics {@link String#startsWith(String)} but takes case-sensitivity * into account. * * @param str the string to check, not null * @param start the start to compare against, not null * @return true if equal using the case rules * @throws NullPointerException if either string is null */ public boolean checkStartsWith(final String str, final String start) { return str.regionMatches(!sensitive, 0, start, 0, start.length()); }
/** * Checks if one string ends with another using the case-sensitivity rule. * <p> * This method mimics {@link String#endsWith} but takes case-sensitivity * into account. * * @param str the string to check, not null * @param end the end to compare against, not null * @return true if equal using the case rules * @throws NullPointerException if either string is null */ public boolean checkEndsWith(final String str, final String end) { final int endLen = end.length(); return str.regionMatches(!sensitive, str.length() - endLen, end, 0, endLen); }
/** * Checks if one string contains another starting at a specific index using the * case-sensitivity rule. * <p> * This method mimics parts of {@link String#indexOf(String, int)} * but takes case-sensitivity into account. * * @param str the string to check, not null * @param strStartIndex the index to start at in str * @param search the start to search for, not null * @return the first index of the search String, * -1 if no match or {@code null} string input * @throws NullPointerException if either string is null * @since 2.0 */ public int checkIndexOf(final String str, final int strStartIndex, final String search) { final int endIndex = str.length() - search.length(); if (endIndex >= strStartIndex) { for (int i = strStartIndex; i <= endIndex; i++) { if (checkRegionMatches(str, i, search)) { return i; } } } return -1; }
/** * Checks if one string contains another at a specific index using the case-sensitivity rule. * <p> * This method mimics parts of {@link String#regionMatches(boolean, int, String, int, int)} * but takes case-sensitivity into account. * * @param str the string to check, not null * @param strStartIndex the index to start at in str * @param search the start to search for, not null * @return true if equal using the case rules * @throws NullPointerException if either string is null */ public boolean checkRegionMatches(final String str, final int strStartIndex, final String search) { return str.regionMatches(!sensitive, strStartIndex, search, 0, search.length()); }
//----------------------------------------------------------------------- /** * Gets a string describing the sensitivity. * * @return a string describing the sensitivity */ @Override public String toString() { return name; }
}12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */
package org.apache.commons.io;
import java.io.IOException;
/** * Subclasses IOException with the {@link Throwable} constructors missing before Java 6. * * @version $Id: IOExceptionWithCause.java 1643107 2014-12-03 13:05:23Z sebb $ * @since 1.4 * @deprecated (since 2.5) use {@link IOException} instead */@Deprecatedpublic class IOExceptionWithCause extends IOException {
/** * Defines the serial version UID. */ private static final long serialVersionUID = 1L;
/** * Constructs a new instance with the given message and cause. * <p> * As specified in {@link Throwable}, the message in the given <code>cause</code> is not used in this instance's * message. * </p> * * @param message * the message (see {@link #getMessage()}) * @param cause * the cause (see {@link #getCause()}). A {@code null} value is allowed. */ public IOExceptionWithCause(final String message, final Throwable cause) { super(message, cause); }
/** * Constructs a new instance with the given cause. * <p> * The message is set to <code>cause==null ? null : cause.toString()</code>, which by default contains the class * and message of <code>cause</code>. This constructor is useful for call sites that just wrap another throwable. * </p> * * @param cause * the cause (see {@link #getCause()}). A {@code null} value is allowed. */ public IOExceptionWithCause(final Throwable cause) { super(cause); }
}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190package org.apache.commons.io;
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */
import java.io.File;import java.io.IOException;import java.lang.reflect.Array;import java.lang.reflect.InvocationTargetException;import java.lang.reflect.Method;
/** * Java7 feature detection and reflection based feature access. * <p/> * Taken from maven-shared-utils, only for private usage until we go full java7 */class Java7Support {
private static final boolean IS_JAVA7;
private static Method isSymbolicLink;
private static Method delete;
private static Method toPath;
private static Method exists;
private static Method toFile;
private static Method readSymlink;
private static Method createSymlink;
private static Object emptyLinkOpts;
private static Object emptyFileAttributes;
static { boolean isJava7x = true; try { ClassLoader cl = Thread.currentThread().getContextClassLoader(); Class<?> files = cl.loadClass("java.nio.file.Files"); Class<?> path = cl.loadClass("java.nio.file.Path"); Class<?> fa = cl.loadClass("java.nio.file.attribute.FileAttribute"); Class<?> linkOption = cl.loadClass("java.nio.file.LinkOption"); isSymbolicLink = files.getMethod("isSymbolicLink", path); delete = files.getMethod("delete", path); readSymlink = files.getMethod("readSymbolicLink", path);
emptyFileAttributes = Array.newInstance(fa, 0); createSymlink = files.getMethod("createSymbolicLink", path, path, emptyFileAttributes.getClass()); emptyLinkOpts = Array.newInstance(linkOption, 0); exists = files.getMethod("exists", path, emptyLinkOpts.getClass()); toPath = File.class.getMethod("toPath"); toFile = path.getMethod("toFile"); } catch (ClassNotFoundException e) { isJava7x = false; } catch (NoSuchMethodException e) { isJava7x = false; } IS_JAVA7 = isJava7x; }
/** * Invokes java7 isSymbolicLink * @param file The file to check * @return true if the file is a symbolic link */ public static boolean isSymLink(File file) { try { Object path = toPath.invoke(file); Boolean result = (Boolean) isSymbolicLink.invoke(null, path); return result.booleanValue(); } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (InvocationTargetException e) { throw new RuntimeException(e); } }
/** * Reads the target of a symbolic link * @param symlink The symlink to read * @return The location the symlink is pointing to * @throws IOException Upon failure */
public static File readSymbolicLink(File symlink) throws IOException { try { Object path = toPath.invoke(symlink); Object resultPath = readSymlink.invoke(null, path); return (File) toFile.invoke(resultPath); } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (InvocationTargetException e) { throw new RuntimeException(e); } }
/** * Indicates if a symlunk target exists * @param file The symlink file * @return true if the target exists * @throws IOException upon error */ private static boolean exists(File file) throws IOException { try { Object path = toPath.invoke(file); final Boolean result = (Boolean) exists.invoke(null, path, emptyLinkOpts); return result.booleanValue(); } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (InvocationTargetException e) { throw (RuntimeException) e.getTargetException(); }
}
/** * Creates a symbolic link * @param symlink The symlink to create * @param target Where it should point * @return The newly created symlink * @throws IOException upon error */ public static File createSymbolicLink(File symlink, File target) throws IOException { try { if (!exists(symlink)) { Object link = toPath.invoke(symlink); Object path = createSymlink.invoke(null, link, toPath.invoke(target), emptyFileAttributes); return (File) toFile.invoke(path); } return symlink; } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (InvocationTargetException e) { final Throwable targetException = e.getTargetException(); throw (IOException) targetException; }
}
/** * Performs a nio delete * * @param file the file to delete * @throws IOException Upon error */ public static void delete(File file) throws IOException { try { Object path = toPath.invoke(file); delete.invoke(null, path); } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (InvocationTargetException e) { throw (IOException) e.getTargetException(); } }
/** * Indicates if the current vm has java7 lubrary support * @return true if java7 library support */ public static boolean isAtLeastJava7() { return IS_JAVA7; }
}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.commons.io;
import java.io.BufferedReader;import java.io.IOException;import java.io.Reader;import java.util.Iterator;import java.util.NoSuchElementException;
/** * An Iterator over the lines in a <code>Reader</code>. * <p> * <code>LineIterator</code> holds a reference to an open <code>Reader</code>. * When you have finished with the iterator you should close the reader * to free internal resources. This can be done by closing the reader directly, * or by calling the {@link #close()} or {@link #closeQuietly(LineIterator)} * method on the iterator. * <p> * The recommended usage pattern is: * <pre> * LineIterator it = FileUtils.lineIterator(file, "UTF-8"); * try { * while (it.hasNext()) { * String line = it.nextLine(); * // do something with line * } * } finally { * it.close(); * } * </pre> * * @version $Id: LineIterator.java 1471767 2013-04-24 23:24:19Z sebb $ * @since 1.2 */public class LineIterator implements Iterator<String> {
// N.B. This class deliberately does not implement Iterable, see https://issues.apache.org/jira/browse/IO-181
/** The reader that is being read. */ private final BufferedReader bufferedReader; /** The current line. */ private String cachedLine; /** A flag indicating if the iterator has been fully read. */ private boolean finished = false;
/** * Constructs an iterator of the lines for a <code>Reader</code>. * * @param reader the <code>Reader</code> to read from, not null * @throws IllegalArgumentException if the reader is null */ public LineIterator(final Reader reader) throws IllegalArgumentException { if (reader == null) { throw new IllegalArgumentException("Reader must not be null"); } if (reader instanceof BufferedReader) { bufferedReader = (BufferedReader) reader; } else { bufferedReader = new BufferedReader(reader); } }
//----------------------------------------------------------------------- /** * Indicates whether the <code>Reader</code> has more lines. * If there is an <code>IOException</code> then {@link #close()} will * be called on this instance. * * @return {@code true} if the Reader has more lines * @throws IllegalStateException if an IO exception occurs */ public boolean hasNext() { if (cachedLine != null) { return true; } else if (finished) { return false; } else { try { while (true) { final String line = bufferedReader.readLine(); if (line == null) { finished = true; return false; } else if (isValidLine(line)) { cachedLine = line; return true; } } } catch(final IOException ioe) { close(); throw new IllegalStateException(ioe); } } }
/** * Overridable method to validate each line that is returned. * This implementation always returns true. * @param line the line that is to be validated * @return true if valid, false to remove from the iterator */ protected boolean isValidLine(final String line) { return true; }
/** * Returns the next line in the wrapped <code>Reader</code>. * * @return the next line from the input * @throws NoSuchElementException if there is no line to return */ public String next() { return nextLine(); }
/** * Returns the next line in the wrapped <code>Reader</code>. * * @return the next line from the input * @throws NoSuchElementException if there is no line to return */ public String nextLine() { if (!hasNext()) { throw new NoSuchElementException("No more lines"); } final String currentLine = cachedLine; cachedLine = null; return currentLine; }
/** * Closes the underlying <code>Reader</code> quietly. * This method is useful if you only want to process the first few * lines of a larger file. If you do not close the iterator * then the <code>Reader</code> remains open. * This method can safely be called multiple times. */ public void close() { finished = true; IOUtils.closeQuietly(bufferedReader); cachedLine = null; }
/** * Unsupported. * * @throws UnsupportedOperationException always */ public void remove() { throw new UnsupportedOperationException("Remove unsupported on LineIterator"); }
//----------------------------------------------------------------------- /** * Closes the iterator, handling null and ignoring exceptions. * * @param iterator the iterator to close */ public static void closeQuietly(final LineIterator iterator) { if (iterator != null) { iterator.close(); } }
}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.commons.io;
import java.io.IOException;import java.io.Serializable;
/** * An {@link IOException} decorator that adds a serializable tag to the * wrapped exception. Both the tag and the original exception can be used * to determine further processing when this exception is caught. * * @since 2.0 */@SuppressWarnings("deprecation") // needs to extend deprecated IOExceptionWithCause to preserve binary compatibility public class TaggedIOException extends IOExceptionWithCause {
/** * Generated serial version UID. */ private static final long serialVersionUID = -6994123481142850163L;
/** * Checks whether the given throwable is tagged with the given tag. * <p> * This check can only succeed if the throwable is a * {@link TaggedIOException} and the tag is {@link Serializable}, but * the argument types are intentionally more generic to make it easier * to use this method without type casts. * <p> * A typical use for this method is in a <code>catch</code> block to * determine how a caught exception should be handled: * <pre> * Serializable tag = ...; * try { * ...; * } catch (Throwable t) { * if (TaggedIOExcepton.isTaggedWith(t, tag)) { * // special processing for tagged exception * } else { * // handling of other kinds of exceptions * } * } * </pre> * * @param throwable The Throwable object to check * @param tag tag object * @return {@code true} if the throwable has the specified tag, * otherwise {@code false} */ public static boolean isTaggedWith(final Throwable throwable, final Object tag) { return tag != null && throwable instanceof TaggedIOException && tag.equals(((TaggedIOException) throwable).tag); }
/** * Throws the original {@link IOException} if the given throwable is * a {@link TaggedIOException} decorator the given tag. Does nothing * if the given throwable is of a different type or if it is tagged * with some other tag. * <p> * This method is typically used in a <code>catch</code> block to * selectively rethrow tagged exceptions. * <pre> * Serializable tag = ...; * try { * ...; * } catch (Throwable t) { * TaggedIOExcepton.throwCauseIfTagged(t, tag); * // handle other kinds of exceptions * } * </pre> * * @param throwable an exception * @param tag tag object * @throws IOException original exception from the tagged decorator, if any */ public static void throwCauseIfTaggedWith(final Throwable throwable, final Object tag) throws IOException { if (isTaggedWith(throwable, tag)) { throw ((TaggedIOException) throwable).getCause(); } }
/** * The tag of this exception. */ private final Serializable tag;
/** * Creates a tagged wrapper for the given exception. * * @param original the exception to be tagged * @param tag tag of this exception */ public TaggedIOException(final IOException original, final Serializable tag) { super(original.getMessage(), original); this.tag = tag; }
/** * Returns the serializable tag object. * * @return tag object */ public Serializable getTag() { return tag; }
/** * Returns the wrapped exception. The only difference to the overridden * {@link Throwable#getCause()} method is the narrower return type. * * @return wrapped exception */ @Override public IOException getCause() { return (IOException) super.getCause(); }
}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.commons.io;
/** * Monitors a thread, interrupting it if it reaches the specified timeout. * <p> * This works by sleeping until the specified timeout amount and then * interrupting the thread being monitored. If the thread being monitored * completes its work before being interrupted, it should <code>interrupt()</code> * the <i>monitor</i> thread. * </p> * * <pre> * long timeoutInMillis = 1000; * try { * Thread monitor = ThreadMonitor.start(timeoutInMillis); * // do some work here * ThreadMonitor.stop(monitor); * } catch (InterruptedException e) { * // timed amount was reached * } * </pre> * * @version $Id: ThreadMonitor.java 1718945 2015-12-09 19:51:14Z krosenvold $ */class ThreadMonitor implements Runnable {
private final Thread thread; private final long timeout;
/** * Start monitoring the current thread. * * @param timeout The timeout amount in milliseconds * or no timeout if the value is zero or less * @return The monitor thread or {@code null} * if the timeout amount is not greater than zero */ public static Thread start(final long timeout) { return start(Thread.currentThread(), timeout); }
/** * Start monitoring the specified thread. * * @param thread The thread The thread to monitor * @param timeout The timeout amount in milliseconds * or no timeout if the value is zero or less * @return The monitor thread or {@code null} * if the timeout amount is not greater than zero */ public static Thread start(final Thread thread, final long timeout) { Thread monitor = null; if (timeout > 0) { final ThreadMonitor timout = new ThreadMonitor(thread, timeout); monitor = new Thread(timout, ThreadMonitor.class.getSimpleName()); monitor.setDaemon(true); monitor.start(); } return monitor; }
/** * Stop monitoring the specified thread. * * @param thread The monitor thread, may be {@code null} */ public static void stop(final Thread thread) { if (thread != null) { thread.interrupt(); } }
/** * Construct and new monitor. * * @param thread The thread to monitor * @param timeout The timeout amount in milliseconds */ private ThreadMonitor(final Thread thread, final long timeout) { this.thread = thread; this.timeout = timeout; }
/** * Sleep until the specified timeout amount and then * interrupt the thread being monitored. * * @see Runnable#run() */ public void run() { try { sleep(timeout); thread.interrupt(); } catch (final InterruptedException e) { // timeout not reached } }
/** * Sleep for a guaranteed minimum number of milliseconds unless interrupted. * * This method exists because Thread.sleep(100) can sleep for 0, 70, 100 or 200ms or anything else * it deems appropriate. Read the docs on Thread.sleep for further interesting details. * @ * @param ms the number of milliseconds to sleep for * @throws InterruptedException if interrupted */ private static void sleep(long ms) throws InterruptedException { long finishAt = System.currentTimeMillis() + ms; long remaining = ms; do { Thread.sleep(remaining); remaining = finishAt - System.currentTimeMillis(); } while (remaining > 0); }
}12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.commons.io.comparator;
import java.io.File;import java.util.Arrays;import java.util.Collections;import java.util.Comparator;import java.util.List;
/** * Abstract file {@link Comparator} which provides sorting for file arrays and lists. * * @version $Id: AbstractFileComparator.java 1415850 2012-11-30 20:51:39Z ggregory $ * @since 2.0 */abstract class AbstractFileComparator implements Comparator<File> {
/** * Sort an array of files. * <p> * This method uses {@link Arrays#sort(Object[], Comparator)} * and returns the original array. * * @param files The files to sort, may be null * @return The sorted array * @since 2.0 */ public File[] sort(final File... files) { if (files != null) { Arrays.sort(files, this); } return files; }
/** * Sort a List of files. * <p> * This method uses {@link Collections#sort(List, Comparator)} * and returns the original list. * * @param files The files to sort, may be null * @return The sorted list * @since 2.0 */ public List<File> sort(final List<File> files) { if (files != null) { Collections.sort(files, this); } return files; }
/** * String representation of this file comparator. * * @return String representation of this file comparator */ @Override public String toString() { return getClass().getSimpleName(); }}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.commons.io.comparator;
import java.io.File;import java.io.Serializable;import java.util.ArrayList;import java.util.Comparator;import java.util.List;
/** * Compare two files using a set of delegate file {@link Comparator}. * <p> * This comparator can be used to sort lists or arrays of files * by combining a number other comparators. * <p> * Example of sorting a list of files by type (i.e. directory or file) * and then by name: * <pre> * CompositeFileComparator comparator = * new CompositeFileComparator( * (AbstractFileComparator) DirectoryFileComparator.DIRECTORY_COMPARATOR, * (AbstractFileComparator) NameFileComparator.NAME_COMPARATOR); * List<File> list = ... * comparator.sort(list); * </pre> * * @version $Id: CompositeFileComparator.java 1642757 2014-12-01 21:09:30Z sebb $ * @since 2.0 */public class CompositeFileComparator extends AbstractFileComparator implements Serializable {
private static final long serialVersionUID = -2224170307287243428L; private static final Comparator<?>[] NO_COMPARATORS = {}; private final Comparator<File>[] delegates;
/** * Create a composite comparator for the set of delegate comparators. * * @param delegates The delegate file comparators */ @SuppressWarnings("unchecked") // casts 1 & 2 must be OK because types are already correct public CompositeFileComparator(final Comparator<File>... delegates) { if (delegates == null) { this.delegates = (Comparator<File>[]) NO_COMPARATORS;//1 } else { this.delegates = (Comparator<File>[]) new Comparator<?>[delegates.length];//2 System.arraycopy(delegates, 0, this.delegates, 0, delegates.length); } }
/** * Create a composite comparator for the set of delegate comparators. * * @param delegates The delegate file comparators */ @SuppressWarnings("unchecked") // casts 1 & 2 must be OK because types are already correct public CompositeFileComparator(final Iterable<Comparator<File>> delegates) { if (delegates == null) { this.delegates = (Comparator<File>[]) NO_COMPARATORS; //1 } else { final List<Comparator<File>> list = new ArrayList<Comparator<File>>(); for (final Comparator<File> comparator : delegates) { list.add(comparator); } this.delegates = (Comparator<File>[]) list.toArray(new Comparator<?>[list.size()]); //2 } }
/** * Compare the two files using delegate comparators. * * @param file1 The first file to compare * @param file2 The second file to compare * @return the first non-zero result returned from * the delegate comparators or zero. */ public int compare(final File file1, final File file2) { int result = 0; for (final Comparator<File> delegate : delegates) { result = delegate.compare(file1, file2); if (result != 0) { break; } } return result; }
/** * String representation of this file comparator. * * @return String representation of this file comparator */ @Override public String toString() { final StringBuilder builder = new StringBuilder(); builder.append(super.toString()); builder.append('{'); for (int i = 0; i < delegates.length; i++) { if (i > 0) { builder.append(','); } builder.append(delegates[i]); } builder.append('}'); return builder.toString(); }}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.commons.io.comparator;
import java.io.File;import java.io.Serializable;import java.util.Comparator;
/** * Compare two files using the <b>default</b> {@link File#compareTo(File)} method. * <p> * This comparator can be used to sort lists or arrays of files * by using the default file comparison. * <p> * Example of sorting a list of files using the * {@link #DEFAULT_COMPARATOR} singleton instance: * <pre> * List<File> list = ... * ((AbstractFileComparator) DefaultFileComparator.DEFAULT_COMPARATOR).sort(list); * </pre> * <p> * Example of doing a <i>reverse</i> sort of an array of files using the * {@link #DEFAULT_REVERSE} singleton instance: * <pre> * File[] array = ... * ((AbstractFileComparator) DefaultFileComparator.DEFAULT_REVERSE).sort(array); * </pre> * <p> * * @version $Id: DefaultFileComparator.java 1642757 2014-12-01 21:09:30Z sebb $ * @since 1.4 */public class DefaultFileComparator extends AbstractFileComparator implements Serializable {
private static final long serialVersionUID = 3260141861365313518L;
/** Singleton default comparator instance */ public static final Comparator<File> DEFAULT_COMPARATOR = new DefaultFileComparator();
/** Singleton reverse default comparator instance */ public static final Comparator<File> DEFAULT_REVERSE = new ReverseComparator(DEFAULT_COMPARATOR);
/** * Compare the two files using the {@link File#compareTo(File)} method. * * @param file1 The first file to compare * @param file2 The second file to compare * @return the result of calling file1's * {@link File#compareTo(File)} with file2 as the parameter. */ public int compare(final File file1, final File file2) { return file1.compareTo(file2); }}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.commons.io.comparator;
import java.io.File;import java.io.Serializable;import java.util.Comparator;
/** * Compare two files using the {@link File#isDirectory()} method. * <p> * This comparator can be used to sort lists or arrays by directories and files. * <p> * Example of sorting a list of files/directories using the * {@link #DIRECTORY_COMPARATOR} singleton instance: * <pre> * List<File> list = ... * ((AbstractFileComparator) DirectoryFileComparator.DIRECTORY_COMPARATOR).sort(list); * </pre> * <p> * Example of doing a <i>reverse</i> sort of an array of files/directories using the * {@link #DIRECTORY_REVERSE} singleton instance: * <pre> * File[] array = ... * ((AbstractFileComparator) DirectoryFileComparator.DIRECTORY_REVERSE).sort(array); * </pre> * <p> * * @version $Id: DirectoryFileComparator.java 1642757 2014-12-01 21:09:30Z sebb $ * @since 2.0 */public class DirectoryFileComparator extends AbstractFileComparator implements Serializable {
private static final long serialVersionUID = 296132640160964395L;
/** Singleton default comparator instance */ public static final Comparator<File> DIRECTORY_COMPARATOR = new DirectoryFileComparator();
/** Singleton reverse default comparator instance */ public static final Comparator<File> DIRECTORY_REVERSE = new ReverseComparator(DIRECTORY_COMPARATOR);
/** * Compare the two files using the {@link File#isDirectory()} method. * * @param file1 The first file to compare * @param file2 The second file to compare * @return the result of calling file1's * {@link File#compareTo(File)} with file2 as the parameter. */ public int compare(final File file1, final File file2) { return getType(file1) - getType(file2); }
/** * Convert type to numeric value. * * @param file The file * @return 1 for directories and 2 for files */ private int getType(final File file) { if (file.isDirectory()) { return 1; } else { return 2; } }}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.commons.io.comparator;
import java.io.File;import java.io.Serializable;import java.util.Comparator;
import org.apache.commons.io.FilenameUtils;import org.apache.commons.io.IOCase;
/** * Compare the file name <b>extensions</b> for order * (see {@link FilenameUtils#getExtension(String)}). * <p> * This comparator can be used to sort lists or arrays of files * by their file extension either in a case-sensitive, case-insensitive or * system dependent case sensitive way. A number of singleton instances * are provided for the various case sensitivity options (using {@link IOCase}) * and the reverse of those options. * <p> * Example of a <i>case-sensitive</i> file extension sort using the * {@link #EXTENSION_COMPARATOR} singleton instance: * <pre> * List<File> list = ... * ((AbstractFileComparator) ExtensionFileComparator.EXTENSION_COMPARATOR).sort(list); * </pre> * <p> * Example of a <i>reverse case-insensitive</i> file extension sort using the * {@link #EXTENSION_INSENSITIVE_REVERSE} singleton instance: * <pre> * File[] array = ... * ((AbstractFileComparator) ExtensionFileComparator.EXTENSION_INSENSITIVE_REVERSE).sort(array); * </pre> * <p> * * @version $Id: ExtensionFileComparator.java 1642757 2014-12-01 21:09:30Z sebb $ * @since 1.4 */public class ExtensionFileComparator extends AbstractFileComparator implements Serializable {
private static final long serialVersionUID = 1928235200184222815L;
/** Case-sensitive extension comparator instance (see {@link IOCase#SENSITIVE}) */ public static final Comparator<File> EXTENSION_COMPARATOR = new ExtensionFileComparator();
/** Reverse case-sensitive extension comparator instance (see {@link IOCase#SENSITIVE}) */ public static final Comparator<File> EXTENSION_REVERSE = new ReverseComparator(EXTENSION_COMPARATOR);
/** Case-insensitive extension comparator instance (see {@link IOCase#INSENSITIVE}) */ public static final Comparator<File> EXTENSION_INSENSITIVE_COMPARATOR = new ExtensionFileComparator(IOCase.INSENSITIVE);
/** Reverse case-insensitive extension comparator instance (see {@link IOCase#INSENSITIVE}) */ public static final Comparator<File> EXTENSION_INSENSITIVE_REVERSE = new ReverseComparator(EXTENSION_INSENSITIVE_COMPARATOR);
/** System sensitive extension comparator instance (see {@link IOCase#SYSTEM}) */ public static final Comparator<File> EXTENSION_SYSTEM_COMPARATOR = new ExtensionFileComparator(IOCase.SYSTEM);
/** Reverse system sensitive path comparator instance (see {@link IOCase#SYSTEM}) */ public static final Comparator<File> EXTENSION_SYSTEM_REVERSE = new ReverseComparator(EXTENSION_SYSTEM_COMPARATOR);
/** Whether the comparison is case sensitive. */ private final IOCase caseSensitivity;
/** * Construct a case sensitive file extension comparator instance. */ public ExtensionFileComparator() { this.caseSensitivity = IOCase.SENSITIVE; }
/** * Construct a file extension comparator instance with the specified case-sensitivity. * * @param caseSensitivity how to handle case sensitivity, null means case-sensitive */ public ExtensionFileComparator(final IOCase caseSensitivity) { this.caseSensitivity = caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity; }
/** * Compare the extensions of two files the specified case sensitivity. * * @param file1 The first file to compare * @param file2 The second file to compare * @return a negative value if the first file's extension * is less than the second, zero if the extensions are the * same and a positive value if the first files extension * is greater than the second file. * */ public int compare(final File file1, final File file2) { final String suffix1 = FilenameUtils.getExtension(file1.getName()); final String suffix2 = FilenameUtils.getExtension(file2.getName()); return caseSensitivity.checkCompareTo(suffix1, suffix2); }
/** * String representation of this file comparator. * * @return String representation of this file comparator */ @Override public String toString() { return super.toString() + "[caseSensitivity=" + caseSensitivity + "]"; }}12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.commons.io.comparator;
import java.io.File;import java.io.Serializable;import java.util.Comparator;
/** * Compare the <b>last modified date/time</b> of two files for order * (see {@link File#lastModified()}). * <p> * This comparator can be used to sort lists or arrays of files * by their last modified date/time. * <p> * Example of sorting a list of files using the * {@link #LASTMODIFIED_COMPARATOR} singleton instance: * <pre> * List<File> list = ... * ((AbstractFileComparator) LastModifiedFileComparator.LASTMODIFIED_COMPARATOR).sort(list); * </pre> * <p> * Example of doing a <i>reverse</i> sort of an array of files using the * {@link #LASTMODIFIED_REVERSE} singleton instance: * <pre> * File[] array = ... * ((AbstractFileComparator) LastModifiedFileComparator.LASTMODIFIED_REVERSE).sort(array); * </pre> * <p> * * @version $Id: LastModifiedFileComparator.java 1642757 2014-12-01 21:09:30Z sebb $ * @since 1.4 */public class LastModifiedFileComparator extends AbstractFileComparator implements Serializable {
private static final long serialVersionUID = 7372168004395734046L;
/** Last modified comparator instance */ public static final Comparator<File> LASTMODIFIED_COMPARATOR = new LastModifiedFileComparator();
/** Reverse last modified comparator instance */ public static final Comparator<File> LASTMODIFIED_REVERSE = new ReverseComparator(LASTMODIFIED_COMPARATOR);
/** * Compare the last the last modified date/time of two files. * * @param file1 The first file to compare * @param file2 The second file to compare * @return a negative value if the first file's lastmodified date/time * is less than the second, zero if the lastmodified date/time are the * same and a positive value if the first files lastmodified date/time * is greater than the second file. * */ public int compare(final File file1, final File file2) { final long result = file1.lastModified() - file2.lastModified(); if (result < 0) { return -1; } else if (result > 0) { return 1; } else { return 0; } }}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.commons.io.comparator;
import java.io.File;import java.io.Serializable;import java.util.Comparator;
import org.apache.commons.io.IOCase;
/** * Compare the <b>names</b> of two files for order (see {@link File#getName()}). * <p> * This comparator can be used to sort lists or arrays of files * by their name either in a case-sensitive, case-insensitive or * system dependent case sensitive way. A number of singleton instances * are provided for the various case sensitivity options (using {@link IOCase}) * and the reverse of those options. * <p> * Example of a <i>case-sensitive</i> file name sort using the * {@link #NAME_COMPARATOR} singleton instance: * <pre> * List<File> list = ... * ((AbstractFileComparator) NameFileComparator.NAME_COMPARATOR).sort(list); * </pre> * <p> * Example of a <i>reverse case-insensitive</i> file name sort using the * {@link #NAME_INSENSITIVE_REVERSE} singleton instance: * <pre> * File[] array = ... * ((AbstractFileComparator) NameFileComparator.NAME_INSENSITIVE_REVERSE).sort(array); * </pre> * <p> * * @version $Id: NameFileComparator.java 1642757 2014-12-01 21:09:30Z sebb $ * @since 1.4 */public class NameFileComparator extends AbstractFileComparator implements Serializable {
private static final long serialVersionUID = 8397947749814525798L;
/** Case-sensitive name comparator instance (see {@link IOCase#SENSITIVE}) */ public static final Comparator<File> NAME_COMPARATOR = new NameFileComparator();
/** Reverse case-sensitive name comparator instance (see {@link IOCase#SENSITIVE}) */ public static final Comparator<File> NAME_REVERSE = new ReverseComparator(NAME_COMPARATOR);
/** Case-insensitive name comparator instance (see {@link IOCase#INSENSITIVE}) */ public static final Comparator<File> NAME_INSENSITIVE_COMPARATOR = new NameFileComparator(IOCase.INSENSITIVE);
/** Reverse case-insensitive name comparator instance (see {@link IOCase#INSENSITIVE}) */ public static final Comparator<File> NAME_INSENSITIVE_REVERSE = new ReverseComparator(NAME_INSENSITIVE_COMPARATOR);
/** System sensitive name comparator instance (see {@link IOCase#SYSTEM}) */ public static final Comparator<File> NAME_SYSTEM_COMPARATOR = new NameFileComparator(IOCase.SYSTEM);
/** Reverse system sensitive name comparator instance (see {@link IOCase#SYSTEM}) */ public static final Comparator<File> NAME_SYSTEM_REVERSE = new ReverseComparator(NAME_SYSTEM_COMPARATOR);
/** Whether the comparison is case sensitive. */ private final IOCase caseSensitivity;
/** * Construct a case sensitive file name comparator instance. */ public NameFileComparator() { this.caseSensitivity = IOCase.SENSITIVE; }
/** * Construct a file name comparator instance with the specified case-sensitivity. * * @param caseSensitivity how to handle case sensitivity, null means case-sensitive */ public NameFileComparator(final IOCase caseSensitivity) { this.caseSensitivity = caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity; }
/** * Compare the names of two files with the specified case sensitivity. * * @param file1 The first file to compare * @param file2 The second file to compare * @return a negative value if the first file's name * is less than the second, zero if the names are the * same and a positive value if the first files name * is greater than the second file. */ public int compare(final File file1, final File file2) { return caseSensitivity.checkCompareTo(file1.getName(), file2.getName()); }
/** * String representation of this file comparator. * * @return String representation of this file comparator */ @Override public String toString() { return super.toString() + "[caseSensitivity=" + caseSensitivity + "]"; }}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.commons.io.comparator;
import java.io.File;import java.io.Serializable;import java.util.Comparator;
import org.apache.commons.io.IOCase;
/** * Compare the <b>path</b> of two files for order (see {@link File#getPath()}). * <p> * This comparator can be used to sort lists or arrays of files * by their path either in a case-sensitive, case-insensitive or * system dependent case sensitive way. A number of singleton instances * are provided for the various case sensitivity options (using {@link IOCase}) * and the reverse of those options. * <p> * Example of a <i>case-sensitive</i> file path sort using the * {@link #PATH_COMPARATOR} singleton instance: * <pre> * List<File> list = ... * ((AbstractFileComparator) PathFileComparator.PATH_COMPARATOR).sort(list); * </pre> * <p> * Example of a <i>reverse case-insensitive</i> file path sort using the * {@link #PATH_INSENSITIVE_REVERSE} singleton instance: * <pre> * File[] array = ... * ((AbstractFileComparator) PathFileComparator.PATH_INSENSITIVE_REVERSE).sort(array); * </pre> * <p> * * @version $Id: PathFileComparator.java 1642757 2014-12-01 21:09:30Z sebb $ * @since 1.4 */public class PathFileComparator extends AbstractFileComparator implements Serializable {
private static final long serialVersionUID = 6527501707585768673L;
/** Case-sensitive path comparator instance (see {@link IOCase#SENSITIVE}) */ public static final Comparator<File> PATH_COMPARATOR = new PathFileComparator();
/** Reverse case-sensitive path comparator instance (see {@link IOCase#SENSITIVE}) */ public static final Comparator<File> PATH_REVERSE = new ReverseComparator(PATH_COMPARATOR);
/** Case-insensitive path comparator instance (see {@link IOCase#INSENSITIVE}) */ public static final Comparator<File> PATH_INSENSITIVE_COMPARATOR = new PathFileComparator(IOCase.INSENSITIVE);
/** Reverse case-insensitive path comparator instance (see {@link IOCase#INSENSITIVE}) */ public static final Comparator<File> PATH_INSENSITIVE_REVERSE = new ReverseComparator(PATH_INSENSITIVE_COMPARATOR);
/** System sensitive path comparator instance (see {@link IOCase#SYSTEM}) */ public static final Comparator<File> PATH_SYSTEM_COMPARATOR = new PathFileComparator(IOCase.SYSTEM);
/** Reverse system sensitive path comparator instance (see {@link IOCase#SYSTEM}) */ public static final Comparator<File> PATH_SYSTEM_REVERSE = new ReverseComparator(PATH_SYSTEM_COMPARATOR);
/** Whether the comparison is case sensitive. */ private final IOCase caseSensitivity;
/** * Construct a case sensitive file path comparator instance. */ public PathFileComparator() { this.caseSensitivity = IOCase.SENSITIVE; }
/** * Construct a file path comparator instance with the specified case-sensitivity. * * @param caseSensitivity how to handle case sensitivity, null means case-sensitive */ public PathFileComparator(final IOCase caseSensitivity) { this.caseSensitivity = caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity; }
/** * Compare the paths of two files the specified case sensitivity. * * @param file1 The first file to compare * @param file2 The second file to compare * @return a negative value if the first file's path * is less than the second, zero if the paths are the * same and a positive value if the first files path * is greater than the second file. * */ public int compare(final File file1, final File file2) { return caseSensitivity.checkCompareTo(file1.getPath(), file2.getPath()); }
/** * String representation of this file comparator. * * @return String representation of this file comparator */ @Override public String toString() { return super.toString() + "[caseSensitivity=" + caseSensitivity + "]"; }}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.commons.io.comparator;
import java.io.File;import java.io.Serializable;import java.util.Comparator;
/** * Reverses the result of comparing two objects using * the delegate {@link Comparator}. * * @version $Id: ReverseComparator.java 1642757 2014-12-01 21:09:30Z sebb $ * @since 1.4 */class ReverseComparator extends AbstractFileComparator implements Serializable {
private static final long serialVersionUID = -4808255005272229056L; private final Comparator<File> delegate;
/** * Construct an instance with the sepecified delegate {@link Comparator}. * * @param delegate The comparator to delegate to */ public ReverseComparator(final Comparator<File> delegate) { if (delegate == null) { throw new IllegalArgumentException("Delegate comparator is missing"); } this.delegate = delegate; }
/** * Compare using the delegate Comparator, but reversing the result. * * @param file1 The first file to compare * @param file2 The second file to compare * @return the result from the delegate {@link Comparator#compare(Object, Object)} * reversing the value (i.e. positive becomes negative and vice versa) */ public int compare(final File file1, final File file2) { return delegate.compare(file2, file1); // parameters switched round }
/** * String representation of this file comparator. * * @return String representation of this file comparator */ @Override public String toString() { return super.toString() + "[" + delegate.toString() + "]"; }
}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.commons.io.comparator;
import java.io.File;import java.io.Serializable;import java.util.Comparator;
import org.apache.commons.io.FileUtils;
/** * Compare the <b>length/size</b> of two files for order (see * {@link File#length()} and {@link FileUtils#sizeOfDirectory(File)}). * <p> * This comparator can be used to sort lists or arrays of files * by their length/size. * <p> * Example of sorting a list of files using the * {@link #SIZE_COMPARATOR} singleton instance: * <pre> * List<File> list = ... * ((AbstractFileComparator) SizeFileComparator.SIZE_COMPARATOR).sort(list); * </pre> * <p> * Example of doing a <i>reverse</i> sort of an array of files using the * {@link #SIZE_REVERSE} singleton instance: * <pre> * File[] array = ... * ((AbstractFileComparator) SizeFileComparator.SIZE_REVERSE).sort(array); * </pre> * <p> * <strong>N.B.</strong> Directories are treated as <b>zero size</b> unless * <code>sumDirectoryContents</code> is {@code true}. * * @version $Id: SizeFileComparator.java 1642757 2014-12-01 21:09:30Z sebb $ * @since 1.4 */public class SizeFileComparator extends AbstractFileComparator implements Serializable {
private static final long serialVersionUID = -1201561106411416190L;
/** Size comparator instance - directories are treated as zero size */ public static final Comparator<File> SIZE_COMPARATOR = new SizeFileComparator();
/** Reverse size comparator instance - directories are treated as zero size */ public static final Comparator<File> SIZE_REVERSE = new ReverseComparator(SIZE_COMPARATOR);
/** * Size comparator instance which sums the size of a directory's contents * using {@link FileUtils#sizeOfDirectory(File)} */ public static final Comparator<File> SIZE_SUMDIR_COMPARATOR = new SizeFileComparator(true);
/** * Reverse size comparator instance which sums the size of a directory's contents * using {@link FileUtils#sizeOfDirectory(File)} */ public static final Comparator<File> SIZE_SUMDIR_REVERSE = new ReverseComparator(SIZE_SUMDIR_COMPARATOR);
/** Whether the sum of the directory's contents should be calculated. */ private final boolean sumDirectoryContents;
/** * Construct a file size comparator instance (directories treated as zero size). */ public SizeFileComparator() { this.sumDirectoryContents = false; }
/** * Construct a file size comparator instance specifying whether the size of * the directory contents should be aggregated. * <p> * If the <code>sumDirectoryContents</code> is {@code true} The size of * directories is calculated using {@link FileUtils#sizeOfDirectory(File)}. * * @param sumDirectoryContents {@code true} if the sum of the directoryies contents * should be calculated, otherwise {@code false} if directories should be treated * as size zero (see {@link FileUtils#sizeOfDirectory(File)}). */ public SizeFileComparator(final boolean sumDirectoryContents) { this.sumDirectoryContents = sumDirectoryContents; }
/** * Compare the length of two files. * * @param file1 The first file to compare * @param file2 The second file to compare * @return a negative value if the first file's length * is less than the second, zero if the lengths are the * same and a positive value if the first files length * is greater than the second file. * */ public int compare(final File file1, final File file2) { long size1 = 0; if (file1.isDirectory()) { size1 = sumDirectoryContents && file1.exists() ? FileUtils.sizeOfDirectory(file1) : 0; } else { size1 = file1.length(); } long size2 = 0; if (file2.isDirectory()) { size2 = sumDirectoryContents && file2.exists() ? FileUtils.sizeOfDirectory(file2) : 0; } else { size2 = file2.length(); } final long result = size1 - size2; if (result < 0) { return -1; } else if (result > 0) { return 1; } else { return 0; } }
/** * String representation of this file comparator. * * @return String representation of this file comparator */ @Override public String toString() { return super.toString() + "[sumDirectoryContents=" + sumDirectoryContents + "]"; }}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><!--Licensed to the Apache Software Foundation (ASF) under one or morecontributor license agreements. See the NOTICE file distributed withthis work for additional information regarding copyright ownership.The ASF licenses this file to You under the Apache License, Version 2.0(the "License"); you may not use this file except in compliance withthe License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License.--><html><body><p>This package provides various {@link java.util.Comparator} implementationsfor {@link java.io.File}s.</p><h3>Sorting</h3><p> All the compartors include <i>convenience</i> utility <code>sort(File...)</code> and <code>sort(List)</code> methods.</p><p> For example, to sort the files in a directory by name:</p> <pre> File[] files = dir.listFiles(); NameFileComparator.NAME_COMPARATOR.sort(files); </pre><p> ...alternatively you can do this in one line:</p><p> <pre> File[] files = NameFileComparator.NAME_COMPARATOR.sort(dir.listFiles()); </pre></p>
<h3>Composite Comparator</h3><p> The <a href="CompositeFileComparator.html">CompositeFileComparator</a> can be used to compare (and sort lists or arrays of files) by combining a number other comparators.</p><p> For example, to sort an array of files by type (i.e. directory or file) and then by name:</p><p> <pre> CompositeFileComparator comparator = new CompositeFileComparator( DirectoryFileComparator.DIRECTORY_COMPARATOR, NameFileComparator.NAME_COMPARATOR); File[] files = dir.listFiles(); comparator.sort(files); </pre></p>
<h3>Singleton Instances (thread-safe)</h3><p> The {@link java.util.Comparator} implementations have some <i>convenience</i> singleton(<i>thread-safe</i>) instances ready to use: <ul> <li><a href="DefaultFileComparator.html">DefaultFileComparator</a> - default file compare: <ul> <li><a href="DefaultFileComparator.html#DEFAULT_COMPARATOR">DEFAULT_COMPARATOR</a> - Compare using <code>File.compareTo(File)</code> method. </li> <li><a href="DefaultFileComparator.html#DEFAULT_REVERSE">DEFAULT_REVERSE</a> - Reverse compare of <code>File.compareTo(File)</code> method. </li> </ul> </li> <li><a href="DirectoryFileComparator.html">DirectoryFileComparator</a> - compare by type (directory or file): <ul> <li><a href="DirectoryFileComparator.html#DIRECTORY_COMPARATOR">DIRECTORY_COMPARATOR</a> - Compare using <code>File.isDirectory()</code> method (directories < files). </li> <li><a href="DirectoryFileComparator.html#DIRECTORY_REVERSE">DIRECTORY_REVERSE</a> - Reverse compare of <code>File.isDirectory()</code> method (directories > files). </li> </ul> </li> <li><a href="ExtensionFileComparator.html">ExtensionFileComparator</a> - compare file extenstions: <ul> <li><a href="ExtensionFileComparator.html#EXTENSION_COMPARATOR">EXTENSION_COMPARATOR</a> - Compare using <code>FilenameUtils.getExtension(String)</code> method. </li> <li><a href="ExtensionFileComparator.html#EXTENSION_REVERSE">EXTENSION_REVERSE</a> - Reverse compare of <code>FilenameUtils.getExtension(String)</code> method. </li> <li><a href="ExtensionFileComparator.html#EXTENSION_INSENSITIVE_COMPARATOR">EXTENSION_INSENSITIVE_COMPARATOR</a> - Case-insensitive compare using <code>FilenameUtils.getExtension(String)</code> method. </li> <li><a href="ExtensionFileComparator.html#EXTENSION_INSENSITIVE_REVERSE">EXTENSION_INSENSITIVE_REVERSE</a> - Reverse case-insensitive compare of <code>FilenameUtils.getExtension(String)</code> method. </li> <li><a href="ExtensionFileComparator.html#EXTENSION_SYSTEM_COMPARATOR">EXTENSION_SYSTEM_COMPARATOR</a> - System sensitive compare using <code>FilenameUtils.getExtension(String)</code> method. </li> <li><a href="ExtensionFileComparator.html#EXTENSION_SYSTEM_REVERSE">EXTENSION_SYSTEM_REVERSE</a> - Reverse system sensitive compare of <code>FilenameUtils.getExtension(String)</code> method. </li> </ul> </li> <li><a href="LastModifiedFileComparator.html">LastModifiedFileComparator</a> - compare the file's last modified date/time: <ul> <li><a href="LastModifiedFileComparator.html#LASTMODIFIED_COMPARATOR">LASTMODIFIED_COMPARATOR</a> - Compare using <code>File.lastModified()</code> method. </li> <li><a href="LastModifiedFileComparator.html#LASTMODIFIED_REVERSE">LASTMODIFIED_REVERSE</a> - Reverse compare of <code>File.lastModified()</code> method. </li> </ul> </li> <li><a href="NameFileComparator.html">NameFileComparator</a> - compare file names: <ul> <li><a href="NameFileComparator.html#NAME_COMPARATOR">NAME_COMPARATOR</a> - Compare using <code>File.getName()</code> method. </li> <li><a href="NameFileComparator.html#NAME_REVERSE">NAME_REVERSE</a> - Reverse compare of <code>File.getName()</code> method. </li> <li><a href="NameFileComparator.html#NAME_INSENSITIVE_COMPARATOR">NAME_INSENSITIVE_COMPARATOR</a> - Case-insensitive compare using <code>File.getName()</code> method. </li> <li><a href="NameFileComparator.html#NAME_INSENSITIVE_REVERSE">NAME_INSENSITIVE_REVERSE</a> - Reverse case-insensitive compare of <code>File.getName()</code> method. </li> <li><a href="NameFileComparator.html#NAME_SYSTEM_COMPARATOR">NAME_SYSTEM_COMPARATOR</a> - System sensitive compare using <code>File.getName()</code> method. </li> <li><a href="NameFileComparator.html#NAME_SYSTEM_REVERSE">NAME_SYSTEM_REVERSE</a> - Reverse system sensitive compare of <code>File.getName()</code> method. </li> </ul> </li> <li><a href="PathFileComparator.html">PathFileComparator</a> - compare file paths: <ul> <li><a href="PathFileComparator.html#PATH_COMPARATOR">PATH_COMPARATOR</a> - Compare using <code>File.getPath()</code> method. </li> <li><a href="PathFileComparator.html#PATH_REVERSE">PATH_REVERSE</a> - Reverse compare of <code>File.getPath()</code> method. </li> <li><a href="PathFileComparator.html#PATH_INSENSITIVE_COMPARATOR">PATH_INSENSITIVE_COMPARATOR</a> - Case-insensitive compare using <code>File.getPath()</code> method. </li> <li><a href="PathFileComparator.html#PATH_INSENSITIVE_REVERSE">PATH_INSENSITIVE_REVERSE</a> - Reverse case-insensitive compare of <code>File.getPath()</code> method. </li> <li><a href="PathFileComparator.html#PATH_SYSTEM_COMPARATOR">PATH_SYSTEM_COMPARATOR</a> - System sensitive compare using <code>File.getPath()</code> method. </li> <li><a href="PathFileComparator.html#PATH_SYSTEM_REVERSE">PATH_SYSTEM_REVERSE</a> - Reverse system sensitive compare of <code>File.getPath()</code> method. </li> </ul> </li> <li><a href="SizeFileComparator.html">SizeFileComparator</a> - compare the file's size: <ul> <li><a href="SizeFileComparator.html#SIZE_COMPARATOR">SIZE_COMPARATOR</a> - Compare using <code>File.length()</code> method (directories treated as zero length). </li> <li><a href="SizeFileComparator.html#SIZE_REVERSE">LASTMODIFIED_REVERSE</a> - Reverse compare of <code>File.length()</code> method (directories treated as zero length). </li> <li><a href="SizeFileComparator.html#SIZE_SUMDIR_COMPARATOR">SIZE_SUMDIR_COMPARATOR</a> - Compare using <code>FileUtils.sizeOfDirectory(File)</code> method (sums the size of a directory's contents). </li> <li><a href="SizeFileComparator.html#SIZE_SUMDIR_REVERSE">SIZE_SUMDIR_REVERSE</a> - Reverse compare of <code>FileUtils.sizeOfDirectory(File)</code> method (sums the size of a directory's contents). </li> </ul> </li> </ul></p>
</body></html>12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.commons.io.filefilter;
import java.io.File;
/** * An abstract class which implements the Java FileFilter and FilenameFilter * interfaces via the IOFileFilter interface. * <p> * Note that a subclass <b>must</b> override one of the accept methods, * otherwise your class will infinitely loop. * * @since 1.0 * @version $Id: AbstractFileFilter.java 1415850 2012-11-30 20:51:39Z ggregory $ */public abstract class AbstractFileFilter implements IOFileFilter {
/** * Checks to see if the File should be accepted by this filter. * * @param file the File to check * @return true if this file matches the test */ public boolean accept(final File file) { return accept(file.getParentFile(), file.getName()); }
/** * Checks to see if the File should be accepted by this filter. * * @param dir the directory File to check * @param name the filename within the directory to check * @return true if this file matches the test */ public boolean accept(final File dir, final String name) { return accept(new File(dir, name)); }
/** * Provide a String representaion of this file filter. * * @return a String representaion */ @Override public String toString() { return getClass().getSimpleName(); }
}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.commons.io.filefilter;
import java.io.File;import java.io.Serializable;import java.util.Date;
import org.apache.commons.io.FileUtils;
/** * Filters files based on a cutoff time, can filter either newer * files or files equal to or older. * <p> * For example, to print all files and directories in the * current directory older than one day: * * <pre> * File dir = new File("."); * // We are interested in files older than one day * long cutoff = System.currentTimeMillis() - (24 * 60 * 60 * 1000); * String[] files = dir.list( new AgeFileFilter(cutoff) ); * for ( int i = 0; i < files.length; i++ ) { * System.out.println(files[i]); * } * </pre> * * @version $Id: AgeFileFilter.java 1642757 2014-12-01 21:09:30Z sebb $ * @see FileFilterUtils#ageFileFilter(Date) * @see FileFilterUtils#ageFileFilter(File) * @see FileFilterUtils#ageFileFilter(long) * @see FileFilterUtils#ageFileFilter(Date, boolean) * @see FileFilterUtils#ageFileFilter(File, boolean) * @see FileFilterUtils#ageFileFilter(long, boolean) * @since 1.2 */public class AgeFileFilter extends AbstractFileFilter implements Serializable {
private static final long serialVersionUID = -2132740084016138541L;
/** The cutoff time threshold. */ private final long cutoff; /** Whether the files accepted will be older or newer. */ private final boolean acceptOlder;
/** * Constructs a new age file filter for files equal to or older than * a certain cutoff * * @param cutoff the threshold age of the files */ public AgeFileFilter(final long cutoff) { this(cutoff, true); }
/** * Constructs a new age file filter for files on any one side * of a certain cutoff. * * @param cutoff the threshold age of the files * @param acceptOlder if true, older files (at or before the cutoff) * are accepted, else newer ones (after the cutoff). */ public AgeFileFilter(final long cutoff, final boolean acceptOlder) { this.acceptOlder = acceptOlder; this.cutoff = cutoff; }
/** * Constructs a new age file filter for files older than (at or before) * a certain cutoff date. * * @param cutoffDate the threshold age of the files */ public AgeFileFilter(final Date cutoffDate) { this(cutoffDate, true); }
/** * Constructs a new age file filter for files on any one side * of a certain cutoff date. * * @param cutoffDate the threshold age of the files * @param acceptOlder if true, older files (at or before the cutoff) * are accepted, else newer ones (after the cutoff). */ public AgeFileFilter(final Date cutoffDate, final boolean acceptOlder) { this(cutoffDate.getTime(), acceptOlder); }
/** * Constructs a new age file filter for files older than (at or before) * a certain File (whose last modification time will be used as reference). * * @param cutoffReference the file whose last modification * time is usesd as the threshold age of the files */ public AgeFileFilter(final File cutoffReference) { this(cutoffReference, true); }
/** * Constructs a new age file filter for files on any one side * of a certain File (whose last modification time will be used as * reference). * * @param cutoffReference the file whose last modification * time is usesd as the threshold age of the files * @param acceptOlder if true, older files (at or before the cutoff) * are accepted, else newer ones (after the cutoff). */ public AgeFileFilter(final File cutoffReference, final boolean acceptOlder) { this(cutoffReference.lastModified(), acceptOlder); }
//----------------------------------------------------------------------- /** * Checks to see if the last modification of the file matches cutoff * favorably. * <p> * If last modification time equals cutoff and newer files are required, * file <b>IS NOT</b> selected. * If last modification time equals cutoff and older files are required, * file <b>IS</b> selected. * * @param file the File to check * @return true if the filename matches */ @Override public boolean accept(final File file) { final boolean newer = FileUtils.isFileNewer(file, cutoff); return acceptOlder ? !newer : newer; }
/** * Provide a String representaion of this file filter. * * @return a String representaion */ @Override public String toString() { final String condition = acceptOlder ? "<=" : ">"; return super.toString() + "(" + condition + cutoff + ")"; }}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.commons.io.filefilter;
import java.io.File;import java.io.Serializable;import java.util.ArrayList;import java.util.Collections;import java.util.List;
/** * A {@link java.io.FileFilter} providing conditional AND logic across a list of * file filters. This filter returns {@code true} if all filters in the * list return {@code true}. Otherwise, it returns {@code false}. * Checking of the file filter list stops when the first filter returns * {@code false}. * * @since 1.0 * @version $Id: AndFileFilter.java 1642757 2014-12-01 21:09:30Z sebb $ * * @see FileFilterUtils#and(IOFileFilter...) */public class AndFileFilter extends AbstractFileFilter implements ConditionalFileFilter, Serializable {
private static final long serialVersionUID = 7215974688563965257L;
/** The list of file filters. */ private final List<IOFileFilter> fileFilters;
/** * Constructs a new instance of <code>AndFileFilter</code>. * * @since 1.1 */ public AndFileFilter() { this.fileFilters = new ArrayList<IOFileFilter>(); }
/** * Constructs a new instance of <code>AndFileFilter</code> * with the specified list of filters. * * @param fileFilters a List of IOFileFilter instances, copied, null ignored * @since 1.1 */ public AndFileFilter(final List<IOFileFilter> fileFilters) { if (fileFilters == null) { this.fileFilters = new ArrayList<IOFileFilter>(); } else { this.fileFilters = new ArrayList<IOFileFilter>(fileFilters); } }
/** * Constructs a new file filter that ANDs the result of two other filters. * * @param filter1 the first filter, must not be null * @param filter2 the second filter, must not be null * @throws IllegalArgumentException if either filter is null */ public AndFileFilter(final IOFileFilter filter1, final IOFileFilter filter2) { if (filter1 == null || filter2 == null) { throw new IllegalArgumentException("The filters must not be null"); } this.fileFilters = new ArrayList<IOFileFilter>(2); addFileFilter(filter1); addFileFilter(filter2); }
/** * {@inheritDoc} */ public void addFileFilter(final IOFileFilter ioFileFilter) { this.fileFilters.add(ioFileFilter); }
/** * {@inheritDoc} */ public List<IOFileFilter> getFileFilters() { return Collections.unmodifiableList(this.fileFilters); }
/** * {@inheritDoc} */ public boolean removeFileFilter(final IOFileFilter ioFileFilter) { return this.fileFilters.remove(ioFileFilter); }
/** * {@inheritDoc} */ public void setFileFilters(final List<IOFileFilter> fileFilters) { this.fileFilters.clear(); this.fileFilters.addAll(fileFilters); }
/** * {@inheritDoc} */ @Override public boolean accept(final File file) { if (this.fileFilters.isEmpty()) { return false; } for (final IOFileFilter fileFilter : fileFilters) { if (!fileFilter.accept(file)) { return false; } } return true; }
/** * {@inheritDoc} */ @Override public boolean accept(final File file, final String name) { if (this.fileFilters.isEmpty()) { return false; } for (final IOFileFilter fileFilter : fileFilters) { if (!fileFilter.accept(file, name)) { return false; } } return true; }
/** * Provide a String representaion of this file filter. * * @return a String representaion */ @Override public String toString() { final StringBuilder buffer = new StringBuilder(); buffer.append(super.toString()); buffer.append("("); if (fileFilters != null) { for (int i = 0; i < fileFilters.size(); i++) { if (i > 0) { buffer.append(","); } final Object filter = fileFilters.get(i); buffer.append(filter == null ? "null" : filter.toString()); } } buffer.append(")"); return buffer.toString(); }
}.gitattributes+134
尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材.zipAdded+3
尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-bin.zipAdded+3
尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src.zipAdded+3
尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/LICENSE.txtAdded+203
尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/NOTICE.txtAdded+5
尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/PROPOSAL.htmlAdded+78
尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/RELEASE-NOTES.txtAdded+993
尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/build.xmlAdded+355
尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/checkstyle.xmlAdded+51
尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/findbugs-exclude-filter.xmlAdded+95
尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/pom.xmlAdded+422
尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/assembly/bin.xmlAdded+49
尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/assembly/src.xmlAdded+41
尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/changes/changes.xmlAdded+488
尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/changes/release-notes.vmAdded+1029
尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/ByteOrderMark.javaAdded+191
尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/Charsets.javaAdded+192
尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/CopyUtils.javaAdded+392
尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/DirectoryWalker.javaAdded+642
尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/EndianUtils.javaAdded+482
尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/FileCleaner.javaAdded+160
尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/FileCleaningTracker.javaAdded+288
尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/FileDeleteStrategy.javaAdded+157
尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/FileExistsException.javaAdded+60
尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/FileSystemUtils.javaAdded+541
尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/FileUtils.javaAdded
尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/FilenameUtils.javaAdded+1452
尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/HexDump.javaAdded+163
尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/IOCase.javaAdded+254
尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/IOExceptionWithCause.javaAdded+67
尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/IOUtils.javaAdded
尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/Java7Support.javaAdded+190
尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/LineIterator.javaAdded+180
尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/TaggedIOException.javaAdded+136
尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/ThreadMonitor.javaAdded+134
尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/comparator/AbstractFileComparator.javaAdded+76
尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/comparator/CompositeFileComparator.javaAdded+122
尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/comparator/DefaultFileComparator.javaAdded+68
尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/comparator/DirectoryFileComparator.javaAdded+81
尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/comparator/ExtensionFileComparator.javaAdded+123
尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/comparator/LastModifiedFileComparator.javaAdded+79
尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/comparator/NameFileComparator.javaAdded+116
尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/comparator/PathFileComparator.javaAdded+117
尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/comparator/ReverseComparator.javaAdded+69
尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/comparator/SizeFileComparator.javaAdded+142
尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/comparator/package.htmlAdded+188
尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/AbstractFileFilter.javaAdded+64
尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/AgeFileFilter.javaAdded+159
尚硅谷Java入门教程,java电子书+Java面试真题(2023新版)/01_课件与电子教材/尚硅谷_第15章_File类与IO流/03-apache-common包/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/AndFileFilter.javaAdded+170